在我的iOS應用程序中,我希望在獲得積極結果後,切換回前一個屏幕。在我的情況下,我會從一個UITableViewController切換回另一個UITableViewController。我曾嘗試過:Swift:如何切換回到之前的UITableViewController而不添加segue
self.dismissViewControllerAnimated(true, completion:nil)
但它不起作用,什麼都不顯示。 我也曾嘗試用:
let mainStoryboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
let vc : UITableViewController = mainStoryboard.instantiateViewControllerWithIdentifier("Tasks") as UITableViewController
self.presentViewController(vc, animated: true, completion: nil)
,但我得到「致命錯誤:意外發現零而展開的可選值」在方法viewWillAppear中():
self.navigationController!.editButtonItem().title = "Modifica"
我用自己能避免從界面生成器添加另一個反向segue,然後執行performSegueWithIdentifier()。沒有更快的方法嗎?
好吧,它可以完美的與navigationController?.popViewControllerAnimated(true)但我不得不使用「self」:XCode需要我,因爲我處在一個處理來自NSURLSession.sharedSession()完成的數據庫響應的閉包中。 dataTaskWithURL() –
啊,在這種情況下,是的,你需要自我。 – rayvinly