-1

I have two UIViewControllers and a UISplitViewController. I am adding UISplitViewController as root on 2nd UIViewController. Here is my code:

[splitViewController setViewControllers:[NSArray arrayWithObjects:rootNav, detailNavigate, nil]];  
        [splitViewController setDelegate:detail];
        self.view.window.rootViewController=splitViewController;

With this code UISplitViewController gets added as root.Now from BACK button on SplitViewController. How to pop to Previous UIViewController? If I use this code, then NavigationBarButton on UIViewController does not work.

[self.navigationController presentViewController:backToView animated:YES completion:nil];

How can i navigate to and from UIViewControllers ?

Sushil Sharma
  • 2,321
  • 3
  • 29
  • 49

1 Answers1

1

IMO, you should set UINavigationController as a window's rootviewcontroller and push splitivewcontroller on it.

e.g.,

[splitViewController setViewControllers:[NSArray arrayWithObjects:rootNav, detailNaviagate, nil]];  
[splitViewController setDelegate:detail];
//self.view.window.rootViewController=splitViewController;
self.navController = [[UINavigationController alloc] initWithRootViewController:splitViewController];
self.window.rootViewController = self.navController; // make root a navigation controller

Now, if you push another view controller on the navigation stack, your back button should work.

NeverHopeless
  • 11,077
  • 4
  • 35
  • 56