4

I am looking for a way to cancel all ongoing modal transition.

I need to push a new view controller at any time of the life cycle of my app, therefore I can't rely on viewDidAppear delegate to start the presentation of this new view.

When one modal transition is already happening and I try to push (with animation) a new controller, I get the "Terminating app due to uncaught exception NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from to while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed crash.

My only alternatives are to push the new controller without animation, or find a way to cancel all pending modal transitions.

Any help?

Alex K
  • 22,315
  • 19
  • 108
  • 236
Guy
  • 97
  • 1
  • 5
  • I had a very similar situation arise - trying to display a "lock screen" whenever the user did a certain action, which could happen at any random time. I don't think there's any way to avoid this scenario - I can't find any way to either check for an app-wide transition in progress, or cancel any transition that's in progress, in order to avoid this exception from occurring. I think the only solution is to present the new view controller separately outside of the existing navigation stack - such as by creating a new `UIWindow` for it. – smileyborg Jun 03 '13 at 22:36
  • Did you find out the solution? – Nam Vu Jan 06 '14 at 20:28

1 Answers1

1

I have used the approach you suggested:

"push the new controller without animation"

Pushing or presenting allow you to not use an animation, so I think it's good enough. As for what @Spynet suggested:

better u just addSubView and do your animation u really don't want modal or push like means...

You shouldn't mix UIViewController's UIViews in other(s) UIViewController('s). The logic of rotation for instance is lost. Also the logic and behaviour of the UIView is also lost. If you want, you can easily create a UIViewController container and work with that. There is a great video about it in the WWDC videos.

Rui Peres
  • 25,741
  • 9
  • 87
  • 137
  • Well actually going with no modal transition between the view changes is a no Go. I need to find a way to cancel the modal transitions ongoing. Any hint on that ? – Guy Sep 13 '12 at 03:18