iphone - UITableView 重新加载数据崩溃

标签 iphone ios objective-c cocoa-touch uitableview

我将 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 时,错误发生了。

错误调用堆栈如下。

enter image description here

输出字符串如下。

-[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/

相关文章:

ios - fatal error : unexpectedly found nil while unwrapping an Optional value (lldb)

iphone - 如何按整数属性对 CoreData 对象数组进行排序?

objective-c - 命令行 Objective-C 程序如何创建其主 NSThread 线程?

iphone - App Store 审批流程中禁止使用第 3 方私有(private) API?

ios - 更改itms-services安装提示信息

ios - 等到 AFJSONRPCClient 请求中的完成 block 未完成

iphone - 无法将 .mp4 视频文件保存到 iphone 相机胶卷?

iphone - 在启动 iPhone 应用程序期间检查互联网连接

ios - 计算形状的距离并显示在 UILabel 中

android - 哪个fb ://url is suitable to trigger the FB application prompting to share content?