1、iOS 11之前的導航欄的高度是64px(狀態(tài)條+導航欄),iOS11之后如果設置了prefersLargeTitles = YES(默認NO)則為96pt。所以一般不用管。
2、在iOS 11上運行tableView向下偏移64px或者20px,因為iOS 11廢棄了automaticallyAdjustsScrollViewInsets,而是給UIScrollView增加了contentInsetAdjustmentBehavior屬性。避免這個坑的方法是要判斷
if (@available(iOS 11.0, *)) {
_tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}else {
self.automaticallyAdjustsScrollViewInsets = NO;
}
tableView出現(xiàn) “上拉加載” 的尾巴,也可以用這個方法。
3、tableView的sectionHeader、sectionFooter高度與設置不符,因為tableView的estimatedRowHeight、estimatedSectionHeaderHeight、 estimatedSectionFooterHeight三個高度估算屬性由默認的0變成了UITableViewAutomaticDimension。最簡單的方法就是直接設置為0。
4、iPhone X狀態(tài)條由20px變成了44px,UITabBar由49px變成了83px。設置布局時y直接寫成64的就要根據(jù)機型設置??梢栽O置宏
#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO),
然后再設置。
5、iPhone X啟動圖大小1125 * 2436,如果啟動圖沒有用xib、storyboard并且沒有設置iPhone X大小。會出現(xiàn)上下黑框,不能完全貼合屏幕。
6、幾個常用的宏
#define StatusBarHeight (iPhoneX ? 44.f : 20.f) ?// 電量條 高
#define? StatusBarAndNavigationBarHeight? (iPhoneX ? 88.f : 64.f)? // 導航欄 高
#define? TabbarHeight (iPhoneX ? (49.f+34.f) : 49.f)? // 分欄 高
7、定位不能使用,因為iOS 11新增了兩個新的權限,NSLocationAlwaysAndWhenInUseUsageDescription 和 NSLocationWhenInUseUsageDescription在plist文件中添加即可。