PushViewController 和发布

发布于 2024-09-25 01:05:40 字数 504 浏览 7 评论 0原文

我正在尝试这样做,带有注释的行效果很好,没有,当我从“推送”视图回来时,我的应用程序崩溃了......我应该什么时候[发布]?或者,更好的是,我这样做是正确的吗?

if (indexPath.row == 1) {
        Credits *cr = [[Credits alloc] initWithNibName:@"Credits" bundle:nil];
        [self.navigationController pushViewController:cr animated:YES];
        //[cr release];
    }else{
        Search *sr = [[Search alloc] initWithNibName:@"Search" bundle:nil];
        [self.navigationController pushViewController:sr animated:YES];
        //[sr release];
    }

I am trying to do like this, with the commented lines it works good, without, when I came back from the "pushed" view my App just crashes... when should I [release]? Or, better, I am doing this correctly?

if (indexPath.row == 1) {
        Credits *cr = [[Credits alloc] initWithNibName:@"Credits" bundle:nil];
        [self.navigationController pushViewController:cr animated:YES];
        //[cr release];
    }else{
        Search *sr = [[Search alloc] initWithNibName:@"Search" bundle:nil];
        [self.navigationController pushViewController:sr animated:YES];
        //[sr release];
    }

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

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

发布评论

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

评论(1

缱绻入梦 2024-10-02 01:05:40

您应该在将控制器推入导航视图控制器的控制器堆栈后释放控制器。我的猜测是,您的 SearchCredits 对象的 dealloc 中发生了其他事情,您在那里过度释放了一个对象。

You should release your controller after pushing it onto the navigation view controller's stack of controllers. My guess is that something else is going on in the dealloc of your Search and Credits objects, that you are overreleasing an object there.

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