問題描述
我正在使用 iOS 5 SDK 創建一個應用程序.我設法使用 Storyboard 的 Segues 推送視圖,但我找不到彈出當前視圖并返回上一個視圖的正確方法.
I am creating an app using iOS 5 SDK. I managed to push views using the Storyboard's Segues, but I cannot find the proper way to pop the current view and go back to the previous one.
我沒有使用任何導航控制器(該應用沒有任何頂部或底部欄).
I am not using any navigationController (the app doesn't have any top or bottom bars).
我認為使用 modal 或 push segue 不是解決方案,因為它會實例化一個新的控制器.
I don't think using modal or push segue the other way would be the solution as it instantiates a new controller.
我是否必須使用帶有相反動畫的自定義 Segue 并在最后刪除視圖?還是有更好的辦法?
Do I have to use a custom Segue with the opposite animation and deletion of the view at the end ? Or is there a better way ?
推薦答案
您可以嘗試從您要關閉的控制器調用 [self dismissViewControllerAnimated:YES completion:nil];
(無論控制器是否有被推送,或模態顯示).
You could try calling [self dismissViewControllerAnimated:YES completion:nil];
from the controller you want to dismiss (whether the controller has been pushed, or shown modally).
這里是相關文檔:UIViewController 類參考
呈現視圖控制器負責關閉它呈現的視圖控制器.如果您在呈現的視圖控制器本身上調用此方法,它會自動將消息轉發到呈現的視圖控制器.
The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, it automatically forwards the message to the presenting view controller.
這篇關于在 iOS 5 上使用 Segues/Storyboard 彈出當前視圖的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!