Created
August 6, 2015 07:51
-
-
Save krisdigital/5aba40753fcb0726b062 to your computer and use it in GitHub Desktop.
Essential Lines to make a UIModalPresentationPopover work on iPhone / iOS 8.3
This file contains hidden or 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
#import "HelpViewController.h" | |
@interface HelpViewController () | |
@end | |
@implementation HelpViewController | |
-(instancetype)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil { | |
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; | |
if (self) { | |
self.modalPresentationStyle = UIModalPresentationPopover; | |
self.popoverPresentationController.delegate = self; | |
self.popoverPresentationController.backgroundColor = [UIColor complementaryColor]; | |
self.preferredContentSize = CGSizeMake(250, 64); | |
self.popoverPresentationController.passthroughViews = nil; | |
} | |
return self; | |
} | |
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller { | |
return UIModalPresentationNone; //You have to specify this particular value in order to make it work on iPhone. | |
} | |
- (UIModalPresentationStyle)adaptivePresentationStyleForPresentationController:(UIPresentationController *)controller traitCollection:(UITraitCollection *)traitCollection { | |
// This method is called in iOS 8.3 or later regardless of trait collection, in which case use the original presentation style (UIModalPresentationNone signals no adaptation) | |
return UIModalPresentationNone; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment