gpt4 book ai didi

iphone - 当我的 viewDidDisappear 时,我尝试释放我的表格。当我回到视野时仍然在那里

转载 作者:行者123 更新时间:2023-11-29 04:42:10 26 4
gpt4 key购买 nike

我像这样声明我的表:

    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];

当我们离开 View 时,我会移除我的 table

-(void) viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
NSLog(@"*viewDidDisappear");
if (videoTable)
{
NSLog(@"removing table");
[videoTable removeFromSuperview];
videoTable.delegate = nil;
[videoTable release];
// self.videoTable = nil;
}
}

当 View 再次加载时,没有表格的迹象,但是..它仍然在那里,因为

-(void) viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self populateFileList];

if (videoTable)
{
NSLog(@"table still here");
}
else
{
NSLog(@"No table");
}
}

有人能解释一下我错过了什么吗?我希望该表完全消失,这样我就可以分配一个新表。

非常感谢,-代码

最佳答案

释放表后需要将其赋值为nil,否则该变量仍然有值(对表对象的旧引用):

[videoTable release];
videoTable = nil;

关于iphone - 当我的 viewDidDisappear 时,我尝试释放我的表格。当我回到视野时仍然在那里,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10235790/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com