我将CustomImageView添加到UITableViewCell。UITableView重载数据崩溃
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上海华]:发送到释放实例0x1f848f30
试试这个:[cell.contentView addSubview:customIV]; – Vishal 2013-03-07 04:09:39
你可以发布'cellForRowAtIndexPath'的完整代码吗? – 2013-03-07 04:14:08
@ttotto您需要在单元格的内容视图中添加子视图,而不是单元格本身。请参阅下面的iManan答案。 – 2013-03-07 04:19:19