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.