以下場景都基于iOS13 beta iphone
,后續(xù)發(fā)現(xiàn)新的問題持續(xù)更新
問題一
場景:一個基于自定義window
的彈窗視圖,點(diǎn)擊其中的某個選項(xiàng)之后嗅义,通過路由跳轉(zhuǎn)到新的視圖控制器
iOS13:未跳轉(zhuǎn)到新的視圖控制器
iOS13之前:功能正常
分析原因
對iOS13和iOS13之前的設(shè)備進(jìn)行了debug
,發(fā)現(xiàn)在iOS13之前柬唯,使用[UIApplication sharedAplication].keyWindow
獲取到的就是最開始創(chuàng)建的window
。但是iOS13之后keywindow
并不是最開始創(chuàng)建的window
, 而是當(dāng)前顯示的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之前運(yùn)行正常吓懈,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
分析原因
上述日志已然很清楚靡狞,就不重復(fù)累贅
這塊代碼返回contentView
也不恰當(dāng)
解決辦法
view.contentView -> view