iOS13 适配

以下场景都基于iOS13 beta iphone,后续发现新的问题持续更新

问题一

场景:一个基于自定义window的弹窗视图,点击其中的某个选项之后,通过路由跳转到新的视图控制器
iOS13:未跳转到新的视图控制器
iOS13之前:功能正常

分析原因

对iOS13和iOS13之前的设备进行了debug,发现在iOS13之前,使用[UIApplication sharedAplication].keyWindow获取到的就是最开始创建的window。但是iOS13之后keywindow并不是最开始创建的window, 而是当前显示的window。

https://stackoverflow.com/questions/57134259/how-to-resolve-keywindow-was-deprecated-in-ios-13-0

'keyWindow' was deprecated in iOS 13.0: Should not be used for applications that support multiple scenes as it returns a key window across all connected scenes

解决办法

[UIApplication sharedApplication].keyWindow -> [UIApplication sharedApplication].windows[0]

问题二

该段代码在iOS13之前运行正常,iOS13之后crash,大致的crash日志如下

 [Assert] UITableViewHeaderFooterView's contentView must remain a direct subview of it. Unexpected superview of the contentView: (null)
 [Assert] UITableViewHeaderFooterView's contentView must remain a direct subview of it. Unexpected superview of the contentView: 
-[UITableView tableViewStyle]: unrecognized selector sent to instance 0x10b69ce00

分析原因

上述日志已然很清楚,就不重复累赘
这块代码返回contentView也不恰当

解决办法

view.contentView -> view
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

友情链接更多精彩内容