我将 CustomImageView 添加到 UITableViewCell。
UITableViewCell *cell = nil;
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell1"] autorelease];
}
CustomImageView *customIV = [[CustomImageView alloc] init];
[cell.contentView addSubView:customIV];
[customIV release];
但是当我尝试重新加载 tableview 时,错误发生了。
错误调用堆栈如下。
输出字符串如下。
-[CustomImageView superview]: message sent to deallocated instance 0x1f848f30
最佳答案
CustomImageView *customIV = [[CustomImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
[cell.contentView addSubView:customIV];
当我释放内存时,它就完成了。
所以根据我的说法,不需要释放,因为它会释放内存。
希望对您有所帮助。
谢谢。
关于iphone - UITableView 重新加载数据崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15262888/