coryalder / DMActivityInstagram

Instagram sharing, iOS 6 style.
MIT License
229 stars 66 forks source link

iOS 7 crash on activityDidFinish #16

Open cannyboy opened 9 years ago

cannyboy commented 9 years ago

I got a crash on iOS 7 on this line, when coming back from Instagram (double-tap home and tap original app):

    [super activityDidFinish:completed];

*** Assertion failure in -[UIWindowController transition:fromViewController:toViewController:target:didEndSelector:animation:], /SourceCache/UIKit/UIKit-2935.138/UIWindowController.m:223
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Attempting to begin a modal transition from <DMResizerViewController: 0x14d5752d0> to <UITabBarController: 0x14d610360> while a transition is already in progress. Wait for viewDidAppear/viewDidDisappear to know the current transition has completed'

iOS 8 seems fine with this.

I solved the issue by waiting a bit in documentInteractionController didEndSendingToApplication

- (void)documentInteractionController:(UIDocumentInteractionController *)controller didEndSendingToApplication:(NSString *)application {
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [self activityDidFinish:YES];
    });
}