如果你有navigationController
做
self.navigationController?.popViewControllerAnimated(false)
否則做
self.dismissViewControllerAnimated(false, completion: nil)
更新
轉到您的故事板,選擇要瀏覽並添加一個故事板ID的視圖控制器。確保點擊「使用故事板ID」
轉到類,你想從瀏覽並添加以下代碼
let storyboard = UIStoryboard(name: "Main", bundle: nil)
// vc is the Storyboard ID that you added
// as! ... Add your ViewController class name that you want to navigate to
let controller = storyboard.instantiateViewControllerWithIdentifier("vc") as! ViewController
self.presentViewController(controller, animated: true, completion: {() -> Void in
})
當你要瀏覽添加該代碼的動作時,使用。
很酷!是在調用segue之前完成的嗎? –
是的,當您想要離開控制器時,請在操作中添加上面的一行。 –
好吧,我做了第一個,但我覺得它是刪除錯誤的視圖控制器,因爲這是行不通的。 –