Skip to content

Instantly share code, notes, and snippets.

@krisdigital
Created August 6, 2015 07:51
Show Gist options
  • Save krisdigital/5aba40753fcb0726b062 to your computer and use it in GitHub Desktop.
Save krisdigital/5aba40753fcb0726b062 to your computer and use it in GitHub Desktop.
Essential Lines to make a UIModalPresentationPopover work on iPhone / iOS 8.3
#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