Forked from steipete/UIPresentationController+HorribleHacks.m
Last active
October 2, 2019 10:35
-
-
Save douglashill/e1e1d6fd3d59a3c59295 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is more hacky than it should be! | |
- (UIModalPresentationStyle)pspdf_currentPresentationStyle { | |
UIViewController *vc = self.presentedViewController.presentingViewController; | |
if ([self respondsToSelector:@selector(adaptivePresentationStyleForTraitCollection:)]) { | |
UIModalPresentationStyle const style = [self adaptivePresentationStyleForTraitCollection:vc.traitCollection]; | |
return (style == UIModalPresentationNone) ? self.presentationStyle : style; | |
} | |
// Before iOS 8.3 we have to fall back on assuming adaptivity is only possible for horizontally compact environments. | |
// UIKit seems to do the same: UIModalPresentationPopover results in popover on iPhone 6 Plus in landscape. | |
if (vc.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact) { | |
UIModalPresentationStyle style = self.adaptivePresentationStyle; | |
if (style != UIModalPresentationNone) { | |
return style; | |
} | |
} | |
return self.presentationStyle; | |
} | |
- (BOOL)pspdf_isPopover { | |
return self.pspdf_currentPresentationStyle == UIModalPresentationPopover; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment