2

I have a UIViewController (A) that modally presents a second view controller (B). Then, that second view controller modally presents a UIImagePickerController (IP). Basically, I have a stack of 2 modal view controllers.

(A) --modally presents--> (B) --modally presents--> (IP)

View controller (A) is the delegate of the image picker, and it dismisses the entire modal stack using:

[self dismissModalViewControllerAnimated:YES];

The problem is with the animation. When dismissing a modal stack like this, the currently visible view should slide off the bottom of the screen, revealing the newly visible view. So in this case, I expect (IP) to slide off the bottom of the screen, revealing the view for (A).

However, what actually happens is this: The image picker view simply disappears, immediately revealing the view for (A), and only the navigation bar animates off the bottom of the screen. The status bar is also left as black translucent instead of transitioning back to a standard gray; this seems to indicate that the image picker normally does some kind of "cleaning up" that isn't being performed when it's dismissed as part of a modal stack.

If I replace the image picker with another generic view controller, the animation works fine. If (IP) is dismissed by (B), the animation also works fine. The problem seems to occur only when dismissing multiple modal view controllers containing UIImagePickerController.

Has anyone seen this before? Any ideas what I might be doing wrong or how to work around this?

James Huddleston
  • 8,410
  • 5
  • 34
  • 39
  • If you call `dismissModalViewControllerAnimated` on A with dismiss B but not IP. If you want you have to call `dismissModalViewControllerAnimated` on B and then `dismissModalViewControllerAnimated` on A. There is no stack of viewcontrollers here, ever view controller can have only one modalview. – rckoenes Jul 05 '11 at 14:58
  • @rckoenes From the `UIViewController` reference under `dismissModalViewControllerAnimated`: "If you present several modal view controllers in succession, and thus build a stack of modal view controllers, calling this method on a view controller lower in the stack dismisses its immediate child view controller and all view controllers above that child on the stack." – James Huddleston Jul 05 '11 at 15:09
  • That is my bad, but i've run into the same problem once before with special viewController (like MFMessageComposeViewController). It should bring you back to viewController A as per apples documentation. It think you should submit a bug repport. – rckoenes Jul 05 '11 at 15:17

1 Answers1

0

Unfortunately, the method dismissModalViewControllerAnimated does not work exactly as you would expect (at least not visually). To achieve what you want, you need to dismiss both modal viewcontrollers in a row, the first non-animated and the second one animated, as described e.g. here.

Community
  • 1
  • 1
Tomas Vana
  • 18,317
  • 9
  • 53
  • 64