开发者

revoking removeFromSuperview?

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

it removes cell.backgroundView from the UIT开发者_运维技巧ableviewCell, but how can I bring it back again ..? (add again that view?)


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜