美文网首页iOS Developer
iOS11&IPhoneX适配(1)

iOS11&IPhoneX适配(1)

作者: MJBaby | 来源:发表于2017-09-20 18:52 被阅读76次

    1、在iOS 11中,会默认开启获取的一个估算值来获取一个大体的空间大小,导致不能正常显示,可以选择关闭。目前尝试在delegate中处理不能很好的解决,不过可以直接设置:

    Swift
    if #available(iOS 11.0, *) {
       self.tabView.estimatedSectionHeaderHeight = 0.01
       self.tabView.estimatedSectionFooterHeight = 0.01
     }
    
    OC
    if (@available(iOS 11.0, *)) {
        self.tableView.estimatedSectionHeaderHeight = 0.01;
        self.tableView.estimatedSectionFooterHeight = 0.01;
    }
    

    2、启动页尺寸不对

    删除原来的LauchImage文件夹,然后添加iOS 11+的启动图片(图片尺寸:1125 * 2436 )
    

    3、在iOS11导航栏多了一个LargeTitleView,专门显示大字标题用的,整个导航栏的高度达到了96p,比之前的导航栏多了32p,不过,大字标题默认是关闭的,所以一般情况下,导航栏的高度还是64p。

    if #available(iOS 11.0, *) {
         self.tabView.contentInsetAdjustmentBehavior = .never
    } else {
         self.automaticallyAdjustsScrollViewInsets = false
    }
    

    对于之前导航栏高度直接写成64的地方做以下替换

    let kStatusHeight = UIApplication.shared.statusBarFrame.size.height
    let navHeight: CGFloat = self.navigationController!.navigationBar.frame.size.height
    let kNavHeight: CGFloat = kStatusHeight + navHeight
    let navView : GradientNavView = GradientNavView(frame: CGRect(x: 0, y: 0, width: screenWidth, height: kNavHeight))
    

    4、iOS11 中 "MBProgressHUD+NJ"不显示弹框

    将原本的
    if (view == nil) {
         view = [[UIApplication sharedApplication].windows lastObject];
    }
    改成
    if (view == nil) {
         view = [UIApplication sharedApplication].keyWindow;
    }
    

    5、无线模拟测试


    配置好后截图.png

    6、iOS11下,如果没有设置estimateRowHeight的值,也没有设置rowHeight的值,那contentSize计算初始值是 44

    随后会不定期更新哟。。。

    相关文章

      网友评论

        本文标题:iOS11&IPhoneX适配(1)

        本文链接:https://www.haomeiwen.com/subject/fkoosxtx.html