回答
要返回到RootViewController的使用:
[self.navigationController popToRootViewControllerAnimated:(BOOL)]
或者去一個特定的控制器:
[self.navigationController popToViewController:
[[self.navigationController viewControllers]
objectAtIndex:THEINDEXOFTHEVIEWCONTROLLERTOUNWINDTO]
animated:YES];
對於更多的細節,請參見我在這篇文章中的回答: Push to root View controller in UIStoryboard
感謝您的回答! – dan 2013-03-07 14:03:11
你可以有一個賽格瑞通過調用UIViewController中這種方法
- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender
你仍然在2次之間的故事板創建SEGUE出現在代碼中,只要確保你的名字和賽格瑞使用在標識符參數
最佳答案。最簡單的,而實際上使用unwind segues! – 2014-07-24 13:33:15
但是,你是不是將推送的VC推入堆棧,而不是移除當前的VC,並讓呈現的VC的前一個實例進入堆棧的頂部? – 2014-12-11 17:39:03
如果你只是想退出之前執行一些代碼的確切名稱(雖然保持簡單,否則,直到返回的東西,你會得到一個UI鎖定),您可以覆蓋你的目標控制器上canPerformUnwindSegueAction:fromViewController:withSender:
。
像這樣的東西可能:
- (BOOL)canPerformUnwindSegueAction:(SEL)action
fromViewController:(UIViewController *)fromViewController
withSender:(id)sender
{
// Some operation...
return YES; // Or NO if something went wrong and you want to abort
}
否則,你實際上可以編程方式創建SEGUE並通過覆蓋segueForUnwindingToViewController:fromViewController:identifier:
管理動畫/開卷邏輯。
- 1. 以編程方式展開segue
- 2. 以編程方式展開segue
- 3. 不能以編程方式展開segue
- 4. 以編程方式解開Segue
- 5. 以編程方式展開/摺疊組
- 6. 如何以編程方式展開NSMenuItem?
- 7. 如何以編程方式展開TreeViewer?
- 8. 以編程方式觸發segue
- 9. 以編程方式設置/激活Segue
- 10. 以編程方式從Xib執行Segue
- 11. iOS處理UIBarButtonItem的方式展開Segue
- 12. 如何以編程方式指定segue(不執行segue)?
- 13. Xcode 6.0.1取消按鈕展開segue
- 14. 展開segue干擾與展示segue
- 15. xcode 4.3.2如何以編程方式更改視圖使用模態segue
- 16. 無法以編程方式在SpriteKit中觸發segue,使用Xcode 8和Swift 3
- 17. Xcode:以編程方式發送短信
- 18. 以編程方式添加按鈕以執行segue
- 19. 以編程方式在iOS8,Xcode 7,Swift 2中打開Apple Maps
- 20. Xcode - 以編程方式打開註釋 - MapKit
- 21. iOS CollectionViewCell展開Segue
- 22. 以編程方式禁用Firefox擴展
- 23. 如何以編程方式擴展卷
- 24. 我如何設置一個模態segue(以編程方式)到一個push segue
- 25. 以編程方式展開ShareActionProvider菜單項的子菜單
- 26. 如何以編程方式打開Chrome擴展頁面
- 27. 以編程方式展開特定的GroupView
- 28. 以編程方式展開(下拉)iPhone狀態欄
- 29. 以編程方式添加edittext時,LinearLayout不會展開
- 30. Flex:以編程方式展開AdvancedDataGrid樹列
Po可以複製[如何以編程方式執行Unwind segue?](https://stackoverflow.com/questions/12509422/how-to-perform-unwind-segue-programmatically) – 2017-12-05 14:51:14