Reputation: 83
I need to replace a view with another view (getting rid of the first view), but all I know are modal views. How do I do this?
Upvotes: 0
Views: 94
Reputation: 1701
A couple different options..
One way is to add a view to your current view. This doesn't "get rid" of your orginal view but it does make it not visible if the new view is in front.
Code would look something like this.
newView = [[NewViewController alloc] initWithNibName:@"NewViewController" bundle:nil];
newView.view.frame = CGRectMake(x,y, newView.view.frame.size.width, newView.view.frame.size.height);
[newView SetMessage:@"my message"]; // set some data for the new view.
[self.view addSubview:newView.view ]; // show new view
Then the new view controller can close itself or just hide itself.
Upvotes: 1
Reputation: 187242
// In a controller method
[oldView removeFromSuperview];
[self.view addSubview:newView];
Upvotes: 3