How to correctly dismiss a UINavigationController that's presented as a modal?

后端 未结 8 1783
情话喂你
情话喂你 2021-02-01 16:04

In my TabBarViewController, I create a UINavigationController and present it as a modal.

var navController =  UINavigationController()
let messageVC         


        
8条回答
  •  有刺的猬
    2021-02-01 16:46

    I suggest you use the other initializer for your UINavigationController:

    let messageVC = self.storyboard?.instantiateViewControllerWithIdentifier("MessagesViewController") as! MessagesViewController
    let navController = UINavigationController(rootViewController: messageVC)
    self.presentViewController(self.navController, animated: true, completion: nil)
    

    To dimiss, simply do

    func swipedRightAndUserWantsToDismiss() {
      self.navigationController.dismissViewControllerAnimated(true, completion: nil)
    }
    

提交回复
热议问题