views:

338

answers:

1

Hi all! I add a view as subview of my uiviewcontroller like this:

// into my ViewController:
UIImageView *imView =[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"img.jpg"]];
imView.frame = CGRectMake(2, 46, 1020, 720);
[self.view addSubview:imView];

now, with another button I wish remove the imView from the subview chain.. how can I do to do this?? thanks

+1  A: 

You can call this method, which belongs to UIView (and UIImageView inherits from UIView)

UIView - (void)removeFromSuperview

vodkhang
thanks! I tried but the uimage view is still in the viewcontroller...I looked into your link and is written that 'Never invoke this method while displaying.'....but i need to remove when displaying...
ghiboz
Are you sure that is "when displaying" not "when it is on display"? You can take a look at this question, it can answer your question:http://stackoverflow.com/questions/1144496/how-to-correctly-removefromsuperview
vodkhang
thanks! I'll try!
ghiboz