3

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

ghiboz
  • 7,863
  • 21
  • 85
  • 131

1 Answers1

5

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

UIView - (void)removeFromSuperview

vodkhang
  • 18,639
  • 11
  • 76
  • 110
  • 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 Jun 12 '10 at 14:00
  • 1
    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 Jun 12 '10 at 14:05