PushViewController 和发布
我正在尝试这样做,带有注释的行效果很好,没有,当我从“推送”视图回来时,我的应用程序崩溃了......我应该什么时候[发布]?或者,更好的是,我这样做是正确的吗?
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该在将控制器推入导航视图控制器的控制器堆栈后释放控制器。我的猜测是,您的
Search
和Credits
对象的 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
andCredits
objects, that you are overreleasing an object there.