0

I am getting one error in iOS 8 in Xcode 6.

Just here is the scenario.

XCode 6 create new Project "Master-Detail Application"

Now I have doing just in detail add one button and in its click event view to Pop Master view but it's not working.

[self.navigationController popViewControllerAnimated:YES];


[self.navigationController popToRootViewControllerAnimated:YES];

Please have a look.

Thanks in advance.

Bhavesh Dhaduk
  • 1,888
  • 15
  • 30
  • Having the exact same problem, except for me "popViewControllerAnimated" doesn't work, while "popToRootViewControllerAnimated" does work! If none are working for you, double check that self.navigationController is not nil. – Bach Nov 05 '14 at 00:40

1 Answers1

3

When using a splitViewController in a Master-Detail application, accessing the navigation controller can be tricky.

This is what I had to do in Swift. Essentially I'm referencing the top view controller of my splitViewController and then casting it as a UINavigationController:

if let navController = splitViewController?.viewControllers[0] as? UINavigationController{
  navController.popViewControllerAnimated(true)
}

Off the top of my head, the Objective-C equivalent would be:

UINavigationController *navController = self.splitViewController.viewControllers[0];
[navcontroller popViewControllerAnimated:YES];

I hope that helps.

Clifton Labrum
  • 13,053
  • 9
  • 65
  • 128