Skip to content

Instantly share code, notes, and snippets.

@OliverLetterer
Last active August 29, 2015 14:00
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save OliverLetterer/11043864 to your computer and use it in GitHub Desktop.
Save OliverLetterer/11043864 to your computer and use it in GitHub Desktop.

When dismissing a view controller on top of a view controller with UIModalPresentationPageSheet or UIModalPresentationFormSheet, the presenting view controllers frame and transform can get miscomputed on iOS 7. Here is a fix I used in SPLSpeechBubblePopoverController:

@implementation UIViewController (SPLSpeechBubblePopoverControllerHack)

+ (void)load
{
    class_swizzleSelector(self, @selector(dismissViewControllerAnimated:completion:), @selector(__SPLSpeechBubblePopoverControllerDismissViewControllerAnimated:completion:));
}

- (void)__SPLSpeechBubblePopoverControllerDismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion
{
    UIViewController *parentViewController = self;
    while (parentViewController.parentViewController) {
        parentViewController = parentViewController.parentViewController;
    }

    BOOL fuckedUpPresentationStyle = parentViewController.modalPresentationStyle == UIModalPresentationPageSheet || parentViewController.modalPresentationStyle == UIModalPresentationFormSheet;
    BOOL transitionWillBeFuckedUp = fuckedUpPresentationStyle && [parentViewController.presentedViewController isKindOfClass:[SPLSpeechBubblePopoverController class]];
    CGAffineTransform correctTransform = parentViewController.view.transform;
    CGRect correctFrame = parentViewController.view.frame;

    [self __SPLSpeechBubblePopoverControllerDismissViewControllerAnimated:flag completion:completion];

    if (transitionWillBeFuckedUp) {
        parentViewController.view.transform = correctTransform;
        parentViewController.view.frame = correctFrame;
    }
}

@end
@ayefremov
Copy link

this bug is valid only for iOS7.0 (fixed in iOS7.1)
Another fix may be presenting QuickLook in pageSheet style

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment