我声明我的表是这样的:
CGRect cgRct = CGRectMake(5, 5, 310, 363);
videoTable = [[UITableView alloc] initWithFrame:cgRct style:UITableViewStylePlain];
videoTable.backgroundColor = [UIColor clearColor];
videoTable.separatorColor = [UIColor whiteColor];
videoTable.separatorStyle = UITableViewCellSeparatorStyleSingleLine;
videoTable.dataSource = self;
videoTable.delegate = self;
videoTable.alwaysBounceVertical = NO;
videoTable.bounces = NO;
videoTable.allowsSelection = YES;
//self.videoTable.layer.zPosition = -1;
//table.dragging = NO;
[self.view addSubview:videoTable];
离开视图时删除我的表
-(void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
NSLog(@"*viewDidDisappear");
if (videoTable)
{
NSLog(@"removing table");
[videoTable removeFromSuperview];
videoTable.delegate = nil;
[videoTable release];
// self.videoTable = nil;
}
}
当视图再次加载时,没有表格的迹象,但是......它仍然存在,因为
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self populateFileList];
if (videoTable)
{
NSLog(@"table still here");
}
else
{
NSLog(@"No table");
}
}
有人可以解释我失踪的是什么吗?我希望表完全消失,所以我可以分配一个新表。
非常感谢, -code
答案 0 :(得分:1)
您需要在释放后为表分配nil,否则,变量仍然有一个值(对表对象的旧引用):
[videoTable release];
videoTable = nil;
答案 1 :(得分:0)
你可以试试这个:
-(void)viewDidUnload{
[super viewDidUnload];
[self setVideoTable:nil];
}
答案 2 :(得分:0)
if(videoTable)为true。因此,您需要在释放后将表分配为nil。