我需要从导航 Controller 中弹出一个 UIViewController。
只是写了这行代码却抛出了异常;
在展开可选值时意外发现 nil
self.navigationController.popViewControllerAnimated(true)
如果我将导航 Controller 设为可选,则此行无效,不会弹出
self.navigationController?.popViewControllerAnimated(true)
如何解决?
最佳答案
您需要正确解包您的 navigationController
if let navController = self.navigationController {
navController.popViewController(animated: true)
}
关于ios - 在 Swift 上弹出 ViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25400476/