pop回上上個頁面導(dǎo)航欄顯示錯誤問題記錄

若想實現(xiàn)從一個頁面pop回上上頁面有兩種方法:

1.使用popToViewController(對應(yīng)視圖控制器,animated:true),這種方法目前沒發(fā)現(xiàn)坑,推薦使用

open func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]?// Pops view controllers until the one specified is on top. Returns the popped controllers.

2.使用setViewControllers(堆棧中視圖控制器數(shù)組,animated:true)

這個方法就是手動設(shè)置當(dāng)前導(dǎo)航欄中視圖控制器數(shù)組,既把需要移除的視圖控制器從該數(shù)組中移除。

在使用這個方法是會有個很奇葩的坑,如果你使用的是系統(tǒng)導(dǎo)航欄,animated必須設(shè)置為true,否則在返回到上上個頁面時,導(dǎo)航欄顯示仍然是移除的那個控制器的導(dǎo)航欄。還有這種情況切記別使用self.navigationController.viewControllers.remove(at:self.navigationController.viewControllers.count - 2),

該方法同樣會出現(xiàn)上述問題,原因暫時不清楚,待俺有時間搞搞清楚

open func setViewControllers(_ viewControllers: [UIViewController], animated: Bool) // If animated is YES, then simulate a push or pop depending on whether the new top view controller was previously in the stack.

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容