天天看點

iOS Presenting view controllers on detached view controllers is discouraged

0x00 一個日志警告⚠️

​Presenting view controllers on detached view controllers is discouraged​

​ 不鼓勵在分離的視圖控制器上呈現視圖控制器

0x01 事發現場

把 ​

​控制器B​

​​ 的 ​

​view​

​​ 添加到 ​

​控制器A​

​​ 的 ​

​view​

​​ 上面

在 ​​

​控制器B​

​​ 内處理了一個視訊播放事件

使用的是 ​​

​AVPlayerViewController​

​​ 結果播放完後,無法​

​關閉​

​了 ?!

檢視控制台

發現系統抛給你一條資訊:

​​

​Presenting view controllers on detached view controllers is discouraged​

​ 滿臉❓❓

0x02 父控制器

經過一翻 ​

​stackoverflow​

​​ 發現了這樣一句關鍵代碼:

​​

​[self.parentViewController presentViewController:viewController animated:YES completion:nil];​

趕緊把 ​

​self​

​​ 改成 ​

​self.parentViewController​

​​ 哦火🔥

不行~

驗證碼輸入框