Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can’t UIImagePickerController be pushed into navigation stack?

When using pushViewController to push UIImagePickerController:

[self.navigationController pushViewController:pvc animated:YES];

an error will occur such as:

Pushing a navigation controller is not supported

The right solution is to use presentModalViewController:

[self presentModalViewController:pvc animated:YES];

Can someone explain why this is necessary? What‘s hidden in UIViewController?

Thanks!

like image 285
Forrest Avatar asked Jan 22 '11 06:01

Forrest


People also ask

What is navigation stack in Swift?

What is a navigation stack? “A navigation controller object manages its child view controllers using an ordered array, known as the navigation stack. The first view controller in the array is the root view controller and represents the bottom of the stack.

How to remove a presented view controller?

To dismiss a modally presented view controller, call the view controller's dismiss(animated:completion:) method.


1 Answers

Apple does not allow stacking of navigation bars. Since the image picker has its own navigation bar, it cannot be placed in a navigation stack. The result would cause user confusion since there would be two bars, two sets of navigation items, two titles, etc.

like image 112
taintedzodiac Avatar answered Sep 21 '22 00:09

taintedzodiac