Discard all modal transitions when introducing a new controller

I am looking for a way to undo all current modality changes.

I need to push a new view controller at any time in the life cycle of my application, so I cannot rely on the viewDidAppear delegate to start the presentation of this new view.

When one modal transition is already happening, and I try to click (with animation) a new controller, I get a "Terminating application due to a crash uncached 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 .

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

Any help?

+4
source share
1 answer

I used the approach you proposed:

"click new controller without animation"

Clicking or presenting eliminates the need for animation, so I think it's good enough. As for what @Spynet suggested:

better at just addSubView and make your animation, and really don't want modal or push tools ...

You should not mix UIViewController's UIViews in other UIViewController('s) . The logic of rotation, for example, is lost. The logic and behavior of the UIView is also lost. If you want, you can easily create a UIViewController container and work with it. WWDC videos have great videos .

+1
source

Source: https://habr.com/ru/post/1433514/


All Articles