ios - 使用 `self.navigationController?.popViewController(animated: true)` 是关闭当前的 ViewController 还是只是返回到前一个?

标签 ios swift uinavigationcontroller

我想知道 self.navigationController?.popViewController(animated: true) 是否真的关闭了正在调用它的 View Controller ,或者它是否只是返回到之前的 View Controller ?如果是这样,这是否意味着我必须在使用上述代码的同时手动关闭 View Controller?谢谢。

最佳答案

当您从 UINavigationController 的导航堆栈中弹出 View Controller 时,UINavigationController 释放弹出的 View Controller ,默认情况下它不存在。您可以通过实现该 View Controller 的 deinit 来看到这一点。

如果您没有看到 deinit 被调用,那么该 View Controller 正在泄漏,因为您有一个保留周期,您需要担心为什么会这样。

关于ios - 使用 `self.navigationController?.popViewController(animated: true)` 是关闭当前的 ViewController 还是只是返回到前一个?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42748989/

相关文章:

ios - Sync 解决 Terminating app due to uncaught exception 'NSGenericException',原因 : '*** Collection <__NSCFSet: > was mutated while being enumerated

ios - 如何在 swift xcode 6.3.1 中导入和使用 SDWebImage

ios - 如何使用分页更改 tableview 自定义单元格中 imageview 的图像。

ios - AWS 忘记密码 : Unable to verify secret hash for client for iOS

ios - 打开ViewController(它是tabBarController中的navigationController)并运行函数

ios - 在 didSet 之后观察 Swift Combine 中 @Published var 的变化?

ios - 将用户文本字段输入附加到其他 View Controller 中的数组中

ios - 跨越新年时获取两个 NSDate 之间的天数

ios - 从 ViewController 移除阴影

ios - 如何在 Subliminal 中断言 UINavigationController 的标题文本?