Swift - 适配iOS 11,部分问题

1. iPhone X tabbar 高度为 83 ,其余机型为49;  导航栏+状态高度为 88,其余为64

官方适配标准如下图:


2. UITableview 顶部出现留白

解决方法: 添加以下代码

    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        return nil
    }
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        return nil
    }

3. iOS 11 弃用 automaticAdjustsScrollViewInsets 新增 contentInsetAdjustmentBehavior

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


4. Xcode9向UIapplication 报告主线程调用 :[UIApplication statusBarOrientation]

Main Thread Checker: UI API called on a background thread: -[UIApplication statusBarOrientation]
PID: 22810, TID: 466328, Thread name: (none), Queue name: WriteLogQueue, QoS: 0
Backtrace:
4   Numerology                          0x0000000107a99468 -[SSDKContext screenResolution] + 88
5   Numerology                          0x0000000107aae942 +[SSDKLog encryptDeviceString] + 390
6   Numerology                          0x0000000107aa6900 __28-[SSDKRunLog getLogContent:]_block_invoke + 59
7   Numerology                          0x0000000107aae769 -[SSDKLog getLogContent:] + 654
8   Numerology                          0x0000000107aa68a6 -[SSDKRunLog getLogContent:] + 127
9   Numerology                          0x0000000107ac9523 __28-[SSDKLogService sendRunLog]_block_invoke + 138
10  libdispatch.dylib                   0x00000001115df3f7 _dispatch_call_block_and_release + 12
11  libdispatch.dylib                   0x00000001115e043c _dispatch_client_callout + 8
12  libdispatch.dylib                   0x00000001115e895b _dispatch_queue_serial_drain + 1162
13  libdispatch.dylib                   0x00000001115e92df _dispatch_queue_invoke + 336
14  libdispatch.dylib                   0x00000001115e507d _dispatch_queue_override_invoke + 733
15  libdispatch.dylib                   0x00000001115ec1f9 _dispatch_root_queue_drain + 772
16  libdispatch.dylib                   0x00000001115ebe97 _dispatch_worker_thread3 + 132
17  libsystem_pthread.dylib             0x0000000111a9c5a2 _pthread_wqthread + 1299
18  libsystem_pthread.dylib             0x0000000111a9c07d start_wqthread + 13

解决方法: 取消勾选部分




5.  关于嵌套tableview后,刷新列表,导致列表向上偏移的问题

原因: iOS 8  引入了Self-Sizing后,我们可以通过estimatedRowHeight来估算每个cell的高度。iOS11 Self-Sizing 默认开启,estimatedRowHeight会由之前的 0 改变为UITableViewAutomaticDimension, 之前项目中,没有使用estimatedRowHeight,在刷新列表的时候,会重新计算 contentSize,进而影响到contentOffSet

解决方法: 
            tableView.estimatedRowHeight = 0.0
            tableView.estimatedSectionFooterHeight = 0.0
            tableView.estimatedSectionHeaderHeight = 0.0


6. 关于iOS 11 新特性: 大标题prefersLargeTitles

显示大标题 

navigationController.navigationBar.prefersLargeTitles = true
修改大标题颜色,字号等

navigationController.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.orange,
                                                                                NSAttributedStringKey.font: UIFont.systemFont(ofSize: 36)]
大标题显示样式

 navigationItem.largeTitleDisplayMode = .automatic
此处说明一下显示样式,默认显示样式为automatic:由前一个界面的设置的显示样式决定。 always:不管其他界面,如何设置,当前只要设置样式为always,则一直显示大标题,不会因界面滚动而显示小标题。  never:与always相反,一直显示小标题




  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值