iOS 11 与 iPhone X的适配

前言

9月20日,正式推送Xcode 9 和iOS 11 的正式版,适配iOS 11是首要的适配的,网上教程很多,不在赘述。这里主要讲的是 iPhone X的适配。大神级别的可以不用看,我这里讲的主要是基础的适配工作

摘要

启动图: 1125 * 2436
statusBar高度: 44
tabbar高度: 83

  • 启动App

对于一些老项目,在启动图上,可能没有采用xib或者SB进行适配的,所以可能会出现如图一,这样导致整个项目运行就会不能完全贴合。

对于一些老项目,在启动图上,可能没有采用xib或者SB进行适配的,所以可能会出现如图一,这样导致整个项目运行就会不能完全贴合。

解决办法,在项目设置里面直接用LaunchScreen.xib或者LaunchScreen.storyboard进行配置启动图,这样项目就会完整显示了

iPhone X LaunchImage.png

iPhone X LaunchImage2.png


login2.png


  • TableView –>MJRefresh

出现下拉刷新的尾巴,该问题很好解决,在文档中标注很明白

@property(nonatomic,assign) BOOL automaticallyAdjustsScrollViewInsets API_DEPRECATED_WITH_REPLACEMENT("Use UIScrollView's contentInsetAdjustmentBehavior instead", ios(7.0,11.0),tvos(7.0,11.0)); // Defaults to YES

contentInsetAdjustmentBehavior对于我们现在来说是个陌生面孔。这是在iOS11中为ScrollView新定义的一个枚举属性。注意,上面谈到的automaticallyAdjustsScrollViewInsets是控制器的属性。

typedef NS_ENUM(NSInteger, UIScrollViewContentInsetAdjustmentBehavior) {
UIScrollViewContentInsetAdjustmentAutomatic, // Similar to .scrollableAxes, but for backward compatibility will also adjust the top & bottom contentInset when the scroll view is owned by a view controller with automaticallyAdjustsScrollViewInsets = YES inside a navigation controller, regardless of whether the scroll view is scrollable
UIScrollViewContentInsetAdjustmentScrollableAxes, // Edges for scrollable axes are adjusted (i.e., contentSize.width/height > frame.size.width/height or alwaysBounceHorizontal/Vertical = YES)
UIScrollViewContentInsetAdjustmentNever, // contentInset is not adjusted
UIScrollViewContentInsetAdjustmentAlways, // contentInset is always adjusted by the scroll view’s safeAreaInsets
} API_AVAILABLE(ios(11.0),tvos(11.0));

iOS 11中的estimatedXXHeight由默认的0变成了现在的默认.AutomaticDimension,导致高度计算出错,最后导致的现象就是上拉加载更多的时候UI错乱,TableView视图的高度异常等一系列问题。

 if (@available(iOS 11.0, *)) {
        _newtableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        //以下是tableview高度计算出现问题
        _newtableView.estimatedRowHeight = 0;
        _newtableView.estimatedSectionHeaderHeight=0;
        _newtableView.estimatedSectionFooterHeight=0;

  }else{
        self.automaticallyAdjustsScrollViewInsets = NO;
  }

iOS 11 NavigationBar 新特性

Navigation 集成 UISearchController
把你的UISearchController赋值给navigationItem,就可以实现将UISearchController集成到Navigation。

navigationItem.searchController //iOS 11 新增属性
navigationItem.hidesSearchBarWhenScrolling //决定滑动的时候是否隐藏搜索框;iOS 11 新增属性

@property (nonatomic, retain, nullable) UISearchController *searchController API_AVAILABLE(ios(11.0)) API_UNAVAILABLE(tvos);

总结:

iOS11系统改变还是比较大的,某些地方需要注意适配,不然会出现很奇怪的现象。暂时,在iOS11遇到这么多坑,以后遇到会继续分享的。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值