我已经投入了数天的时间来试图弄清楚发生了什么事情,并且对于我的生活我看不到我做错了什么。当用户触摸屏幕上的一个点时,我弹出一个UIPopover。弹出窗口有一个选项卡控制器和表格视图,显示关于该点的信息。但是,当酥料饼被驳回,它崩溃声称: - [UIAnimator removeAnimationsForTarget:]:消息发送到释放实例UIPopoverController中的内存崩溃
这里被加载视图控制器代码:
MyViewController *popView = [[MyViewController alloc] init];
myPop = [[UIPopoverController alloc] initWithContentViewController:pop];
[popView release];
myPop.delegate = self;
[airportPop setPopoverContentSize:popView.view.frame.size];
[airportPop presentPopoverFromRect:CGRectMake(location.x,location.y,1,1) inView:self.mainView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
- (void)dismissPopover {
if(myPop != nil) {
[myPop dismissPopoverAnimated:YES];
[myPop.delegate popoverControllerDidDismissPopover:airportPop];
}
}
- (void)popoverControllerDidDismissPopover:(UIPopoverController *)popoverController {
[myPop release];
myPop = nil;
}
实际MyViewController是只是一个UIViewController与(删节为了简洁)初始化:
- (id)init
{
self = [super init];
//create a newview
self.view = popView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, POPUP_WIDTH, POPUP_HEIGHT)];
[popView release];
topBar = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, POPUP_WIDTH, 30)];
....
[popView addSubview:topBar];
[topBar release];
//create a table view
self.table = [[UITableView alloc] initWithFrame:CGRectMake(0, 30, POPUP_WIDTH, POPUP_HEIGHT-30-49)];
table.delegate = table.dataSource = self;
....
//create a tab bar
tabBar = [[UITabBar alloc] initWithFrame:CGRectMake(0, POPUP_HEIGHT-49, POPUP_WIDTH, 49)];
tabBar.delegate = self;
[popView addSubview:tabBar];
[popView addSubview:table];
[tabBar release];
[table release];
return(self);
}
dealloc的无非是[超级的dealloc]因为一切基本上是由视图拥有和视图控制器会照顾Ø多f it。当myPop发布时,在DidDismissPopover中,视图也被释放,所以这似乎工作正常。但不久之后,我发生了这起事故。
当弹出窗口关闭时,我是否需要做一些特殊的操作来放弃标签视图或表格视图?
我在表中的单元格上使用autorelease,我应该停止这样做吗?
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
预先感谢您的帮助!任何想法都非常感谢!
-Kevin
什么是'popView'? –