1.iPhoneX基本属性
启动图尺寸:1125px × 2436px(即 375pt × 812pt @3x))
iphoneX 屏幕高:812.0个点
导航栏高度+状态栏高度:88.0个点(导航栏高度仍是44个点,状态栏高度增高为44个点,所以刘海的高度并不是状态栏的高度。状态栏和导航栏平分了头部总的高度)
tabbar高度:83.0个点(原是固定49个点,增高了34个点。所以)
2.MJRefresh错位等 使用UIScrollview的控件的页面造成的页面错位
iOS11废弃了automaticallyAdjustsScrollViewInsets属性,需要使用scrollview的contentInsetAdjustmentBehavior属性。
3.替换写死的状态栏高度20 导航栏44 和64。安全起见替换写死的tabbar高度49
4.UITableView中的UITableViewStyleGrouped类型设置heightForHeaderInSection失效
在iOS11上,原来使用UITableViewStyleGrouped设置的sectionheader高度可能失效。本人发现两种解决办法
方法一:.在iOS11上tableview的style使用UITableViewStylePlain。
然后在代理中照常设置就好了
方法二。所有系统下都使用UITableViewStyleGrouped,然后同时实现以下四个代理方法(在iOS11下,对应的sectionHeaderHeight和sectionHeaderView要成对存在,之前只设置sectionHeaderHeight也可以,所以规范起见:统一成双入对)
5.contentInset失效。iOS11下引入了safeArea的概念。需要注意这几个属性:
iOS11下当你没有设置contentInsetAdjustmentBehavior时,系统会自动为你将试图添加到安全区域。
如下图所示区域
所以,此时你如果仍然设置了contentInset,比如下面的代码
就会出现下方多了49个点。
解决办法仍然是两个:
方法一:
方法二:
6.代码块调用失效
Xcode9中原来设置的代码块可能会失效。这个问题比较蛋疼。你去多打开几个 多点一下edit,多换一下completion scopes可能就恢复了。
7.contentInsetAdjustmentBehavior详解
以下引自腾讯bugly博文。(简单地说就是UIScrollViewContentInsetAdjustmentNever相当于以前的automaticallyAdjustsScrollViewInsets=NO,此时你可屏蔽系统自动调整,布局由你自己支配。其他三个属性基本是系统帮你将视图添加到safeArea里面)
/* Configure the behavior of adjustedContentInset.
Default is UIScrollViewContentInsetAdjustmentAutomatic.
*/@property(nonatomic) UIScrollViewContentInsetAdjustmentBehavior contentInsetAdjustmentBehavior
adjustContentInset表示contentView.frame.origin偏移了scrollview.frame.origin多少;是系统计算得来的,计算方式由contentInsetAdjustmentBehavior决定。有以下几种计算方式:
1.UIScrollViewContentInsetAdjustmentAutomatic:如果scrollview在一个automaticallyAdjustsScrollViewContentInset = YES的controller上,并且这个Controller包含在一个navigation controller中,这种情况下会设置在top & bottom上 adjustedContentInset = safeAreaInset + contentInset不管是否滚动。其他情况下与UIScrollViewContentInsetAdjustmentScrollableAxes相同
2.UIScrollViewContentInsetAdjustmentScrollableAxes: 在可滚动方向上adjustedContentInset = safeAreaInset + contentInset,在不可滚动方向上adjustedContentInset = contentInset;依赖于scrollEnabled和alwaysBounceHorizontal / vertical = YES,scrollEnabled默认为yes,所以大多数情况下,计算方式还是adjustedContentInset = safeAreaInset + contentInset
3.UIScrollViewContentInsetAdjustmentNever: adjustedContentInset = contentInset
4.UIScrollViewContentInsetAdjustmentAlways: adjustedContentInset = safeAreaInset + contentInset
当contentInsetAdjustmentBehavior设置为UIScrollViewContentInsetAdjustmentNever的时候,adjustContentInset值不受SafeAreaInset值的影响。