0
votes

in my application i mentioned the tab bar controller with 2 tabs tab1 and tab2.And each tab having the navigation view controller with root view controllers.And my scenario is like below

tab1 -> viewcontroller1 (navigationcontroller rootviewcontroller) -> viewcontroller2.

So now i want to move directly from app delegate to view controller2.How is it possible.

I did this one like this in app delegate. But it's moving to viewcontroller1.

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
                                                         bundle: nil];
self.tabbarController = [mainStoryboard instantiateViewControllerWithIdentifier:@"tabbarcontroller"];
[self.tabbarController setSelectedIndex:1];
 viewcontroller2 *view =(viewcontroller2 *) [mainStoryboard instantiateViewControllerWithIdentifier:@"view2"];

[self.tabbarController.navigationController pushViewController:view animated:YES];
self.window.rootViewController=self.tabbarController;
1
Can you push viewcontroller2 as navigationController's top view?Jakehao
in appDelegate --> did finish lounching with option write : Splash *vc2 = [[Splash alloc] initWithNibName:@"Splash" bundle:nil]; self.navigationController = [[UINavigationController alloc] initWithRootViewController:vc2];Devang Goswami
setSelectedIndex:2 i think it will move to second viewcontrollerUttam Sinha
Your tab bar controller doe not have a navigation controller, so self.tabbarController.navigationController is nil.rdelmar
self.tabbarcontroller.navigationcontroller is readonly.Gsr Ios

1 Answers

0
votes
Tab1 -> Viewcontroller1(navigationcontroller rootviewcontroller) -> Viewcontroller2

I have used this approach some times

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main"
                                                         bundle: nil];
self.tabbarController = [mainStoryboard instantiateViewControllerWithIdentifier:@"tabbarcontroller"];
[self.tabbarController setSelectedIndex:1];
viewcontroller1 *view1 =(viewcontroller1 *) [mainStoryboard instantiateViewContro1llerWithIdentifier:@"view1"];
viewcontroller2 *view2 =(viewcontroller2 *) [mainStoryboard instantiateViewControllerWithIdentifier:@"view2"];

[self.tabbarController.navigationController pushViewController:view1 animated:NO];
[self.tabbarController.navigationController pushViewController:view2 animated:YES];

self.window.rootViewController=self.tabbarController;