iOS11遇到的坑及解决方法

1、iOS 11之前的导航栏的高度是64px(状态条+导航栏),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出现 “上拉加载” 的尾巴,也可以用这个方法。

3、tableView的sectionHeader、sectionFooter高度与设置不符,因为tableView的estimatedRowHeight、estimatedSectionHeaderHeight、 estimatedSectionFooterHeight三个高度估算属性由默认的0变成了UITableViewAutomaticDimension。最简单的方法就是直接设置为0。

4、iPhone X状态条由20px变成了44px,UITabBar由49px变成了83px。设置布局时y直接写成64的就要根据机型设置。可以设置宏

#define iPhoneX ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(1125, 2436), [[UIScreen mainScreen] currentMode].size) : NO),

然后再设置。

5、iPhone X启动图大小1125 * 2436,如果启动图没有用xib、storyboard并且没有设置iPhone X大小。会出现上下黑框,不能完全贴合屏幕。

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文件中添加即可。

你可能感兴趣的:(iOS11遇到的坑及解决方法)