Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UIViewController remove subview

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

like image 902
ghiboz Avatar asked Sep 01 '26 20:09

ghiboz


1 Answers

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

UIView - (void)removeFromSuperview

like image 190
vodkhang Avatar answered Sep 07 '26 08:09

vodkhang



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!