lovoo / LVModalQueue

This fixes 'NSInternalInconsistencyException's when presentViewController: and dismissViewController: are called, while a transition is already in progress. Transitions are queued for later execution.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

LVModalQueue

This fixes 'NSInternalInconsistencyException's when presentViewController: and dismissViewController: are called, while a transition is already in progress. Transitions are queued for later execution.

Build Status Carthage compatible

Quick start

LVModalQueue is available on CocoaPods.

Add the following to your Podfile:

pod 'LVModalQueue', :git => 'https://github.com/Lovoo/LVModalQueue'

Done! You don't have to import anything or change your existing code!

Sample

Sample image

Motivation

If a presentation or dismissal is currently in progress, when starting another one, a NSInternalInconsistencyException is thrown because a transition is already in progress.

Having a big app with a lot of external frameworks comes with a lot of challenges.

One of them is, that most of this frameworks tend to present their UIViewControllers on [UIApplication sharedApplication].keyWindow.rootViewController. Having truly interactive UIViewController transitions could also lead to multiple concurrent presentations as the user can start a transition, while an old one is still running.

Implementation

LVModalQueue hooks into presentations and dismissals by swizzling into UIViewControllers presentViewController:animated:completion: and dismissViewControllerAnimated:completion: methods. If a transition is currently animating, it is queued for later execution when the transition is finished.

Supported iOS Versions

LVModalQueue was tested on iOS 7 and above in the LOVOO App with millions of users and reduced our crashes with concurrent transitions to zero.

About

This fixes 'NSInternalInconsistencyException's when presentViewController: and dismissViewController: are called, while a transition is already in progress. Transitions are queued for later execution.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:Objective-C 94.6%Language:Ruby 5.4%