
How to remove previous view in iPhone application on loading a new subview on it?

i have listed all the possible ways to remove the subview from superview in iPhone application?
[myView removeFromSuperview]; //if you have only one view to remove
// or
for (UIView *view in self.subviews) {
[view removeFromSuperview];
}
// or
for (UIView *view in [self.view subviews]) {
[view removeFromSuperview];
}
//or
// Assuming *view is already set up as a UIView...
for (int i = 0; i < [[self.view subviews] count]; i++ ) {
[[[self.view subviews] objectAtIndex:i] removeFromSuperview];
}
// or
[[[self view] subviews] makeObjectsPerformSelector: @selector(removeFromSuperview)];
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.