Applicable to UITableView and iosuitableview in IOS 11

Source: Internet
Author: User

Applicable to UITableView and iosuitableview in IOS 11

In May September, Apple released IOS11 and Iphone X. The hardware of this operating system has made great effort for developers to adapt. Let's take a look at IOS 11, where the pain points need to be adapted:

1. The UI of UIScrollView and its subclass is completely normal before IOS 11, but a wonderful interface is displayed on IOS 11.

(1) Check UITablevIew first.

The original automaticallyAdjustsScrollViewInsets in VC expired. in IOS 11, APPLE recommends that you use the contentInsetAdjustmentBehavior attribute of UIScrollView to set the content margin of the scroll view for automatic calculation.

@ Property (nonatomic, assign) BOOL automaticallyAdjustsScrollViewInsets

This attribute of UIScrollView in IOS 11 SDK

@ Property (nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior // This property is of the enumeration type

{

UIScrollViewContentInsetAdjustmentAutomatic, // scrollView automatically calculates and adapts to the top and bottom padding andNot scrollThe padding is also set.

UIScrollViewContentInsetAdjustmentScrollableAxes, // automatically adapts to the margin

UIScrollViewContentInsetAdjustmentNever, // has the same effect as automaticallyAdjustsScrollViewInsets = NO, without calculating the padding

UIScrollViewContentInsetAdjustmentAlways // calculate the padding according to safeAreaInsets (security zone)

}

Therefore, in IOS 11, you need to set ScrollView:

Self. tableView. contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;

If you need global settings, you need to set them as follows:

If (@ available (iOS 11.0 ,*)){

 

[[UIScrollView appearance] setContentInsetAdjustmentBehavior: UIScrollViewContentInsetAdjustmentNever];

}

In this way, when UITableview, UICollectionView, and UIScrollview are used, you do not need to set this attribute separately, because UIView and its subclass follow the UIAppearance protocol.

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.