IOS development-automaticallyAdjustsScrollViewInsets attributes

Source: Internet
Author: User

IOS development-automaticallyAdjustsScrollViewInsets attributes
This is a problem recently encountered. Generally, an App has a UINavigationController. If TableView on the top has tableHeaderView, if the starting position is (), it is under the navigation bar, in order to better enable the UI, you may encounter this problem from the screen (0, 0). Let's take a brief look at the effect: the main code is as follows:-(UITableView *) tableView {if (! _ TableView) {_ tableView = [[UITableView alloc] initWithFrame: CGRectMake (0, 0, CGRectGetWidth (self. view. bounds), CGRectGetHeight (self. view. bounds) style: UITableViewStylePlain]; // _ tableView. tableFooterView = [[UIView alloc] init]; _ tableView. rowHeight = 40.0; _ tableView. sectionHeaderHeight = 0.0; _ tableView. sectionFooterHeight = 0.0; _ tableView. dataSource = self; _ tableView. delegate = self;} retu Rn _ tableView;}-(NSInteger) tableView :( UITableView *) tableView numberOfRowsInSection :( NSInteger) section {return 5;} // http://www.cnblogs.com/xiaofeixiang technical exchange: 228407086-(UITableViewCell *) tableView :( UITableView *) tableView cellForRowAtIndexPath :( NSIndexPath *) indexPath {UITableViewCell * cell = [[UITableViewCell alloc] init]; cell. textLabel. text = @ "-FlyElephant"; return cell;} set automaticallyAdjus at this time The effect of tsScrollViewInsets is as follows: the official documents are explained as follows: A Boolean value that indicates whether the view controller shocould automatically adjust its scroll view insets. declarationSWIFTvar automaticallyAdjustsScrollViewInsets: BoolOBJECTIVE-C @ property (nonatomic, assign) BOOL determines default value of this property is YES, which allows the view controller to adjust its scroll view Insets in response to the screen areas consumed by the status bar, navigation bar, and toolbar or tab bar. set to NO if you want to manage scroll view inset adjustments yourself, such as when there is more than one scroll view in the view hierarchy. availabilityAvailable in iOS 7.0 and later. to put it simply, automaticallyAdjustsScrollViewInsets automatically adjusts the inset of the scrollview according to the status bar, navigationbar, and tabbar of the UI., Set it to no. we can modify the layout by ourselves instead of making adjustments to viewController ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.