【发布时间】:2016-01-02 20:59:17
【问题描述】:
我有两个视图控制器,ViewControllerA 和 ViewControllerB,嵌入在 UINavigationController 中。 ViewControllerA 有一个 UICollectionView 可以显示图像。
当位于索引 0 和 UICollectionViewCell 的相机图标被选中时,它应该关闭 ViewControllerA 并显示 ViewControllerB。此外,还有一个ViewController 以模态方式呈现ViewControllerA
这就是我所做的,但它只会关闭 ViewControllerA 并且没有任何反应
let controller = self.storyboard?.instantiateViewControllerWithIdentifier("cameraViewController") as! UINavigationController
self.dismissViewControllerAnimated(true, completion: { () -> Void in
self.presentingViewController?.presentViewController(controller, animated: true, completion: nil)
})
【问题讨论】:
-
presentingViewController为零吗? -
它没有抛出任何错误。我通过添加断点来调试它。它运行了代码,只是没有对它做出反应
-
如果它是nil,它不会抛出错误,因为你使用
self.presentingViewController?而不是self.presentingViewController!,如果它是nil,那很可能是问题的原因 - 试试打印self.presentingViewController,看看结果如何。
标签: ios swift uinavigationcontroller