gpt4 book ai didi

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

转载 作者:塔克拉玛干 更新时间:2023-11-02 07:51:37 25 4
gpt4 key购买 nike

首先:我将我的应用程序移植到 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/

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