Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Programmatically switching MVC view controllers - iOS

How do I programmatically switch the view controller in iOS?

So example - I have a menu MVC setup, now I click "Help" How do I programmatically hand this off to the help view controller to load that MVC setup?

like image 565
dbobrowski Avatar asked Nov 14 '10 15:11

dbobrowski


1 Answers

Is this a View-based or Navigation-based application?

For a Navigation-based application, your AppDelegate should provide you access to a shared UINavigationController which you can use to push/pop UIViewControllers

[self.navController pushViewController:helpViewController animated:YES]

then when the user wants to leave the Help view and go back to the main screen, you would pop it off. This functionality is provided automatically by the left/back button in the UINavigationBar, but you can trigger it manually using the popViewcontrollerAnimated selector:

[self.navController popViewControllerAnimated:YES]

For View-based applications, you move between screens by manipulating the subviews

[window addSubview:helpViewController.view]
like image 136
Jay Avatar answered Nov 15 '22 08:11

Jay