美文网首页
iOS11适配

iOS11适配

作者: 动机至善私心了无 | 来源:发表于2017-11-07 17:20 被阅读193次

1.在iOS11系统上跑不起来项目,log输出nw_proxy_resolver_create_parsed_array PAC evaluation error: NSURLErrorDomain: -1004
这是因为在Mac系统中设置了网络自动代理而导致
解决方案:系统偏好设置 → 网络 → 高级 → 代理 → 取消自动代理配置

2.在iphone X上崩溃.Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIStatusBar_Modern 0x7fc1f0c11700> valueForUndefinedKey:]: this class is not key value coding-compliant for the key foregroundView.'
原来版本的友盟plus有问题,更新就好了,(如果不行,就是因为别的问题导致此崩溃)

3.Main Thread Checker: UI API called on a background thread: -[UIApplication applicationState]
PID: 1708, TID: 268523, Thread name: (none), Queue name: com.apple.root.default-qos.overcommit, QoS: 21
Backtrace:
警告是因为原本需要在主线程执行的代码被放在了子线程里边,shareSDK 中把状态栏设置在子线程,所以输出此警告,可以在scheme 里边取消主线程检测(如图),不过不建议如此

9A91DE76-5D7F-4A8F-BA52-93B9551AE798.png

4.在我们自己封装tabbarController,并且重新封装tabbar的时候,不要用

self.viewControllers = navLists;

这种写法, 在iOS11上会出现不默认选中tabbarItem的BUG.
使用

[self addChildViewController:nav];

这种写法即可

5.iOS11系统上有时tableView会下移20个像素点,使用contentInsetAdjustmentBehavior代替automaticallyAdjustsScrollViewInsets.

//如果是iOS11的系统, 则不自动调整内边距
    if (@available(iOS 11.0, *))
    {
        if ([self.tableView respondsToSelector:@selector(setContentInsetAdjustmentBehavior:)]) {
            self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
        }
    }
  1. 在iphoneX上头部和尾部空出一部分.
    只要添加一个iPhoneX尺寸的启动图就可以了.iPhoneX对应像素 1125 * 2436

  2. 在iOS11上,有时候使用上啦加载更多,会遇到刷新之后,页面闪动到别的位置,比如cell上移,或者cell下移了.关掉iOS11的Self-Sizing(iOS 11默认开启).

self.tableView.estimatedSectionHeaderHeight = 0;
self.tableView.estimatedSectionFooterHeight = 0;
self.tableView.estimatedRowHeight = 0;

注意要加上if (@available(iOS 11.0, *)),如

    if (@available(iOS 11.0, *))
    {
        self.tableView.estimatedSectionHeaderHeight = 0;
        self.tableView.estimatedSectionFooterHeight = 0;
        self.tableView.estimatedRowHeight = 0;
    }

//参考文章

  1. iOS11、iPhone X、Xcode9 适配指南

  2. iPhoneX 适配笔记

  3. Xcode9 和iOS11适配和特性

  4. iOS 11 安全区域适配总结

  5. ios11适配 以及会有的坑 持续更新。。。

  6. iOS11和iPhone X的适配

相关文章

网友评论

      本文标题:iOS11适配

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