iphone - 当呈现为模态视图 Controller 时,ARC UINavigationController 堆栈不会被释放

标签 iphone ios uinavigationcontroller modal-dialog automatic-ref-counting

首先:我将我的应用程序移植到 ARC,一切似乎都正常。但现在我发现了一个问题:我有一个 UINavigationController,它以模态方式呈现,其堆栈上有一些 UIViewController。但是当我关闭模态视图 Controller 时,堆栈中的 View Controller 似乎没有被释放。这是我所做的:

UIViewController* root = [[UIViewController alloc] init];
UINavigationController* navi = [[UINavigationController alloc] initWithRootViewController:root];
[self presentModalViewController:navi animated:TRUE];

然后我从根开始推送更多 View Controller ,但这并不重要。事实是当我稍后打电话

[self dismissModalViewControllerAnimated:TRUE];

root 不会被释放。当然,在我的代码根目录中是 UIViewController 的子类,我跟踪 dealloc 和 viewDidUnload,但没有调用任何东西。

有什么想法吗?

最佳答案

你的导航 Controller 里面有什么?可能是其他东西(可能是导航 Controller 中的 View Controller )是罪魁祸首,它在链中处于领先地位,这意味着导航 Controller 没有被释放。

无论哪种方式,您发布的代码都是正确的,因此如果您的导航 Controller 在调用 dismissModalViewController 后未被释放,则表明其他内容仍然对它或其其中之一具有事件引用依赖项。我知道这不能回答您的问题,但您可能需要四处寻找。

关于iphone - 当呈现为模态视图 Controller 时,ARC UINavigationController 堆栈不会被释放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8727316/

相关文章:

ios - TableView 导航到 View Controller 和其他单元格中的其他操作

php - 将图片从 iOS 应用程序发送到 php 脚本到 mySQL DB

ios - Xcode 8.0 NSManagedObject 子类模板在哪里

swift - 以编程方式打开 View Controller 并且看不到导航栏。 swift 3

ios - 苹果是否允许应用程序让用户将图像发布到论坛等共享页面?

iphone - 如何使用触摸旋转图像

iphone - 在 iPhone 上渲染波形

objective-c - iOS:如何使用 MPMoviePlayerController

ios - 如何将一个 ViewController 从左侧推到另一个

ios swift - 返回到隐藏导航栏的屏幕时,导航项背景变黑