【发布时间】:2011-12-26 20:13:30
【问题描述】:
我试图弄清楚为什么使用 didSelectRowAtIndexPath 在我的 tableView 中推送 viewController 会导致 iOS 4.3 崩溃,但在 iOS 5.0+ 中,它可以正常工作。
当我打电话时它就崩溃了:
self.customViewController = [[[CustomViewController alloc] initWithNibName:@"CustomViewController"bundle:nil] autorelease];
第一次推送 customViewController 之后的任何时间。
这是我的相关代码:
@property (nonatomic, retain) CustomViewController *customViewController;
-(void) dealloc // Dealloc of tableView.
{
[customViewController release];
customViewController = nil;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
self.customViewController = [[[CustomViewController alloc] initWithNibName:@"CustomViewController"bundle:nil] autorelease]; // Release old, allocate new, set it.
[[self navigationController] pushViewController:customViewController animated:YES];
[customViewController release]; // Balance out pushViewController's retain.
}
谢谢。
【问题讨论】:
标签: iphone ios uitableview crash pushviewcontroller