tags:

views:

53

answers:

2

hi, I have code like...

[((UIImageView *)cell.backgroundView) removeFromSuperview];

it removes cell.backgroundView from the UITableviewCell, but how can I bring it back again ..? (add again that view?)

+1  A: 
[cell addSubview:myBackgroundView]

Where the myBackgroundView is a UIImageView. If you keep myBackgroundView as an instance variable, you could simply add it again. If you do not, you need to reinitialize the backgroundView;

UIImageView *myBackgroundView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"your image"]] autorelease];

Something like that.

MiRAGe
A: 

You will need to keep a reference to the superview, and use addSubview:

UIView *imageView = (UIView *)cell.backgroundView;
UIView *imageSuperview = imageView.superView; // I assume it's cell, but just in case

// Remove imageView
[imageView removeFromSuperview];

// Add it again
[imageSuperview addSubview:imageView];

If you store the imageView in fields and such, please ensure that you retain your references properly.

notnoop