我已經投入了數天的時間來試圖弄清楚發生了什麼事情,並且對於我的生活我看不到我做錯了什麼。當用戶觸摸屏幕上的一個點時,我彈出一個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'? –