开发者

Image VIew problem

How can i remove an ImageView added on a dynamically created UIView, so that i ca开发者_运维技巧n add another ImageView on my UIView.


You either add a tag for that UIImageView and find it based on tag or loop throughout the subviews and look for an object of class UIImageView containing the image you need to change.


Easiest way is probably with tags. So...

UIImageView *removeMe = [[UIImageView alloc] init];
removeMe.image = [UIImage imageNamed:@"theImage.png"];
removeMe.tag = 1;
[theView addSubview:removeMe];
[removeMe release]; //theView now retains it!

...then later:

UIImageView *removalTarget = (UIImageView *)[theView viewWithTag:1];
[removalTarget removeFromSuperview];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜