Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS removing view

I have two views, viewA and viewB. I load viewB on top of viewA with

[self.view addSubview: viewB.view];

I wan't to remove viewB, but I don't how to do it. I tried

[self.view removeFromSuperview];

but this isn't working. How can I do this?

like image 834
McDermott Avatar asked Dec 18 '11 17:12

McDermott


2 Answers

Call -removeFromSuperview on viewB.view.

like image 50
Sean Avatar answered Oct 05 '22 08:10

Sean


To remove viewB's view from its superview, you need to call removeFromSuperview on that view.

[viewB.view removeFromSuperview];

From the UIView class reference.

removeFromSuperview

Unlinks the receiver from its superview and its window, and removes it from the responder chain.

like image 37
Till Avatar answered Oct 05 '22 09:10

Till