Rightpoint / RZUtils

Rightpoint Commonly Used Tools
Other
123 stars 22 forks source link

Don't assert multiple transitions on RZSingleChildContainerViewController #126

Open ZevEisenberg opened 9 years ago

ZevEisenberg commented 9 years ago

@Raizlabs/maintainers-ios @ndonald2 I have a bug that I'm looking that in a project where RZSingleChildContainerViewController is asserting because we're trying to initiate a transition when there is already a transition happening. The assertion is as follows:

- (void)setContentViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(RZSingleChildContainerViewControllerCompletionBlock)completion
{
    if ( self.isTransitioning ) {
        [NSException raise:NSInternalInconsistencyException format:@"%@: Cannot start a transition while a transition is already in place.", [self class]];
    }

I was going to fix it in my project, but I could also fix it in this repo. I would add a single-item queue, so if you try to do a transition while another is already happening, it adds it to a "pending transition" internal property, and executes the pending transition, if any, once the current one is done. I presume it would also execute the initial completion block before the new animation starts.

Thoughts?

KingOfBrian commented 9 years ago

I know this has been causing a number of crashes in SS, and this would be an easy way to avoid the crash. :+1:

ZevEisenberg commented 9 years ago

Another question: should we change the behavior of the existing API, so that it just works instead of crashing? Or should we add a method like setContentViewController:animated:completion:performAfterCurrentTransitionIfOneHappensToCurrentlyBeInFlight?