UIViewController 的 dealloc 中的 [super dealloc] 在 iPad 中出现问题

发布于 2024-11-17 21:04:20 字数 985 浏览 6 评论 0原文

我正在开发一个应用程序,我将一个视图控制器推送到 UINavigationController 上,并在导航控制器保留它时立即释放它。当我弹出视图控制器时,将按预期调用 dealloc 方法但问题是应用程序崩溃了。如果我通过启用 NSZombie 在 GDB 中观察到它说 -[MyViewController isKindOfClass:]: 消息发送到已释放的实例0x6847a00如果我从视图控制器的dealloc方法中删除[super dealloc],它的工作就很好。我没有其他东西dealloc 方法除了 [super dealloc] 之外。这里可能有什么问题,任何人都可以帮忙。代码片段如下:

MyViewController *myViewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];
myViewController.path = selectedPath; //very important to set path here
myViewController.parentViewController = self;
[self cleanBookshelf];
[self.navigationController pushViewController:myViewController animated:NO];
[myViewController release];
[indicatorView removeFromSuperview];
[loadingindicator stopAnimating];

我正在 myViewController 的一个操作方法中弹出

-(IBAction)goBack:(UIButton*)sender{
[self.navigationController popViewControllerAnimated:YES];

}

I am working on an application where i am pushing one view controller on to a UINavigationController and releasing it immediately as the navigation controller retains it.When i am poping the view controller the dealloc method is being called as expected but the problem is the app is getting crashed.If i observe in GDB by enabling NSZombie its saying that -[MyViewController isKindOfClass:]: message sent to deallocated instance 0x6847a00.If i remove [super dealloc]from my view controller's deallocmethod its working just fine.I have nothing else in dealloc method except [super dealloc].What could be the problem here, can any one please help.The code snippet is below:

MyViewController *myViewController = [[MyViewController alloc] initWithNibName:nil bundle:nil];
myViewController.path = selectedPath; //very important to set path here
myViewController.parentViewController = self;
[self cleanBookshelf];
[self.navigationController pushViewController:myViewController animated:NO];
[myViewController release];
[indicatorView removeFromSuperview];
[loadingindicator stopAnimating];

and i am poping in one action method of myViewController as

-(IBAction)goBack:(UIButton*)sender{
[self.navigationController popViewControllerAnimated:YES];

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

筑梦 2024-11-24 21:04:20

只是猜测,但我怀疑问题出在这一行:

myViewController.parentViewController = self;

UIViewController 的 parentViewController 属性被标记为 readonly,我认为这是一个强烈的信息,您不应该这样做搞乱它。

Just guessing, but I suspect that the problem is with this line:

myViewController.parentViewController = self;

UIViewController's parentViewController property is marked readonly, and I'd take that as a strong message that you shouldn't mess with it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文