Remove From Super View - removeFromSuperview
In iPhone application programming, UIView contain number of methods to manage the view hierarchy such as
etc... But in this post we are going to explore how to remove super view from view hierarchy. Whenever we use the method "removeFromSuperview", it actually removes the view from responder chain. It's method can be write as given method...
and whenever we call this method it releases the view that means if you are willing to load it again (in case of swapping views) you required to retain it before calling the method removeFromSuperview.
In this example we are calling this method on button click.
The example contains, two views rootviewC and myviewC (second view). And we are adding myviewC as a subview onto the rootviewC. The application has a table that shows the list of array as item. On clicking the list item it will call the second view.
And in the second view we have a button with action & function on it, that removes view from the super view. Remember that you can remove the UIView that is added as subview. To add the view as subview just follow the given code.
myViewController *ViewController =[[myViewController alloc]initWithNibName:@"myViewController" bundle:nil];
On building the application you will get the following output.