detailViewController = [[DetailViewController alloc] initWithNibName:@"DetailViewController_iPad" bundle:nil];
[self.splitViewController.splitViewController viewWillDisappear:YES];
detailViewController.strDetailId = [teaserSectionOneArray objectAtIndex:indexValue] ;
NSMutableArray *viewControllerArray = [[NSMutableArray alloc] initWithArray:[[self.splitViewController.viewControllers objectAtIndex:1] viewControllers]];
[viewControllerArray removeAllObjects];
[viewControllerArray addObject:detailViewController];
[[self.splitViewController.viewControllers objectAtIndex:1] setViewControllers:viewControllerArray animated:NO];
[self.splitViewController.splitViewController viewWillAppear:YES];
[viewControllerArray release];
This code using for push to the detail view. How do I pop to another view controller in detail view when I click the button? Its not supported the [self.navigationController popViewControllerAnimated:YES];. How to handle this problem? Thanks in advance!
Wooooow thats NOT how you push a view controller on the stack of a navigationController !!
You don’t have to call
viewWillDisappear,viewWillAppearand such yourself ! You don’t have to add thedetailViewControllerto thesplitViewController.viewControllersarray yourself either!What you need to do is this:
NavigationControlleras part of itsdetailViewController(namely the ViewController that is on the right of the screen should be anUINavigationController, not a regularUIViewController).UINavigationController. The fact that yourUINavigationControlleris the right part of anUISplitViewControlleris not different than when you use anUINavigationControllerin any other context.Simply use
pushViewController:animated:andpopViewControllerAnimated:methods ofUINavigationControllerto push and pop your view controllers. Access yourUINavigationControllerfrom yourUISplitViewControllerusing either a customIBOutletthat you added to point to it, or by accessing(UINavigationController*)[self.splitViewController.viewControllers objectAtIndex:1].