I saw a message for How to switch button views on iPhone? but it doesn’t answer how to switch between views using buttons. The person who asked the question decided to answer that they can switch between views using the uinavigationcontroller.
I put the following code in ibaction, which starts when the button is clicked in the main view.
PhoneNumberViewController *phoneNumberViewController1 = [[PhoneNumberViewController alloc] initWithNibName:@"PhoneNumberView2" bundle:nil];
self.phoneNumberViewController = phoneNumberViewController1;
[self.view removeFromSuperview];
[self.view insertSubview: phoneNumberViewController1.view atIndex:0];
When this code executes the whole view, it is simply empty. If I omit the removefromsuperview part, then the view disappears behind my button, but the button still remains. I'm not sure if this is the right way to switch between the buttons, but if anyone knows how to do this, please help. Also, if anyone knows of any sample projects that switch between views using buttons, let me know.
Thank you, million!
source
share