Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UITableView reloadData crash

I added CustomImageView to the 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];

But when I try to reload tableview, the error occurs.

error call stack is same as follows.

enter image description here

Output string is as follows.

-[CustomImageView superview]: message sent to deallocated instance 0x1f848f30

like image 882
ttotto Avatar asked Apr 21 '26 12:04

ttotto


1 Answers

CustomImageView *customIV = [[CustomImageView alloc] initWithFrame:CGRectMake(x, y, w, h)];
[cell.contentView addSubView:customIV];

It's done with me when I've released memory.
So according to me, No need to release, because it'll deallocated memory.

Hopefully, it'll help you.
Thanks.

like image 191
Manann Sseth Avatar answered Apr 23 '26 03:04

Manann Sseth