[英]Can't pop iOS viewController. Not sure, but I think it's something with the Navigation Controller
[英]Can't pop viewController
我正在使用以下代碼來顯示UIViewController:
CATransition *transition = [CATransition animation];
transition.duration = 0.f;
transition.type = kCATransitionFade;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
[self.navigationController pushViewController:newVC animated:NO];
並且viewController正確顯示。 然后,我使用以下代碼來准備動畫(用於制作流行動畫):
CATransition *transition = [CATransition animation];
transition.duration = 0.f;
transition.type = kCATransitionFade;
[self.navigationController.view.layer addAnimation:transition forKey:nil];
但是,這些行都不會彈出它:
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController popToRootViewControllerAnimated:NO];
可能是什么問題? 記錄導航堆棧會顯示兩個正確的UIViewControllers
:
NSLog(@"%@", self.navigationController.viewControllers);
這很清楚
如果您不推送 yourViewcontroller,則無法彈出yourViewController
如果您的代碼中缺少波紋管
[self.navigationController pushViewController:newVC animated:NO];
雙方都不會執行
[self.navigationController popViewControllerAnimated:NO];
[self.navigationController popToRootViewControllerAnimated:NO];
好的,這很尷尬。
我在viewDidAppear:animated:
中運行推調用,但是我忘記執行檢查是否已經推過。 因此,當我彈出新的UIViewController
, viewDidAppear:animated
再次重新按下了新的VC。 我還將其設置為animate:NO
並刪除了自定義過渡,從而導致彈出和重新推動基本上是瞬間發生的。
我通過在彈出消息中放置一個斷點發現了這一點,並注意到模擬器顯示了根UIViewController
一秒鍾。
將您的navigationItems左/右/標題設置為nil之前
[self.navigationController popViewControllerAnimated:NO];
我今天看到了類似的東西,彈出后視圖沒有更新
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.