Breaking News
Home / iOS / iOS Isuses / Pushing a navigation controller is not supported in iOS?

Pushing a navigation controller is not supported in iOS?

Issue

When trying to display an Navigation Controller like ABPeoplePickerNavigationController into the navigation flow it displays an error.

        ABPeoplePickerNavigationController *ppnc = [[ABPeoplePickerNavigationControlleralloc] init];
        ppnc.peoplePickerDelegate = self;
       
        [self.navigationController pushViewController:ppnc animated:YES];

        
Error
2011-08-26 23:31:08.982 ContactShark[11860:207] <0x7128470 LauncherViewController.m:(356)> Did click  with URL AB Contacts
2011-08-26 23:31:09.124 ContactShark[11860:207] *** Terminating app due to uncaught exception ‘NSInvalidArgumentException’, reason: ‘Pushing a navigation controller is not supported’
*** Call stack at first throw:
(
0   CoreFoundation                      0x01ee35a9 __exceptionPreprocess + 185
1   libobjc.A.dylib                     0x02037313 objc_exception_throw + 44
2   UIKit                               0x00f13340 -[UINavigationController pushViewController:transition:forceImmediate:] + 386
3   UIKit                               0x00f0c1c4 -[UINavigationController pushViewController:animated:] + 62
4   ContactShark                        0x0010faa8 -[LauncherViewController launcherView:didSelectItem:] + 36

Solution

By design you cannot push a navigation controller onto of another navigation controller, so instead display as modal view controller.

[self presentModalViewController:ppnc animated:YES];

[pb_builder]

Check Also

Signing Identities, Missing Private Key, Cannot sign App

Issue Cannot sign the App in XCode, says Missing Private Key. <!

Advertisment ad adsense adlogger