I declare my table like so:
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];
I remove my table when we leave the view
-(void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
NSLog(@"*viewDidDisappear");
if (videoTable)
{
NSLog(@"removing table");
[videoTable removeFromSuperview];
videoTable.delegate = nil;
[videoTable release];
// self.videoTable = nil;
}
}
When the view loads again there is no sign of the table, but.. it is still there because
-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self populateFileList];
if (videoTable)
{
NSLog(@"table still here");
}
else
{
NSLog(@"No table");
}
}
Can anybody explain what it is that I am missing? I want the table completely gone, so I can alloc a new table.
Many Thanks,
-Code
You need to assign nil to the table after you release it, otherwise, the variable still have a value (an old reference to the table object):