gpt4 book ai didi

ios - 关闭一个 UINavigationController 并呈现另一个 UINavigationController

转载 作者:搜寻专家 更新时间:2023-10-31 22:47:31 28 4
gpt4 key购买 nike

我有两个 View Controller ,ViewControllerAViewControllerB,嵌入在 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)
})

最佳答案

当 View Controller 被关闭时,我的猜测是 self 已经被释放,所以 self.presentingViewController? 也变成了 nil。我会在取消操作发生之前创建一个对呈现 View Controller 的强烈引用:

let presentingViewController = self.presentingViewController
self.dismissViewControllerAnimated(true) { completed in
if completed {
presentingViewController?.presentViewController(controller, animated: true, completion: nil)
}
}

另外,首先确保 self.presentingViewController 不是 nil

关于ios - 关闭一个 UINavigationController 并呈现另一个 UINavigationController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34570666/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com