This is didFinishLaunchingWithOptions Method in AppDelegate. Let me explain scenario, I have developed sideMenu like facebook in my app, but now I have to change the sideMenu list according to screens (ViewController)
Here the side Menu is SideMenuViewController, which is an argument in contain, which ultimately becomes window's rootViewController.
SO, The very basic question arises is "How to change the controller or variable which becomes rootViewController of windows"
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
SideMenuViewController *leftMenuViewController = [[SideMenuViewController alloc] init];
self.container = [ContainerOfSideMenuByVeerViewController
containerWithCenterViewController:[self navigationController]
leftMenuViewController:leftMenuViewController];
self.window.rootViewController = self.container;
[self.window makeKeyAndVisible];
return YES;
}
If any programmer wants to know more code or requirement, I do welcome to provide by editing my code or in comments.
If you are starter like me ( both iOS and OSX mechine ) and you wanted to change the entry point within same storyboard, then, -> long press on the entry point arrow. -> drag it to the view controller you wish to make the starting point, the arrow will now move to your new screen.
Specifying the Initial View Controllerstoryboard and select the Tab Bar Controller Scene. On the right, select the Attribute inspector. You'll find a checkbox named Is Initial View Controller. Checking this box will identify the selected view controller as the initial entry point for the storyboard you're on.
Try this:
<YourAppDelegateClass> *app = [[UIApplication sharedApplication] delegate];
app.window.rootViewController = <YourRootViewController>;
Don't forget to include necessary headers (your AppDelegate, for example) or you'll get CE. This one seems to work:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With