Skip to content

Instantly share code, notes, and snippets.

@acalism
Created August 27, 2015 13:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save acalism/70d488733ad67a46c4ac to your computer and use it in GitHub Desktop.
Save acalism/70d488733ad67a46c4ac to your computer and use it in GitHub Desktop.
if ([UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPad) { // iPad
if ([UIPopoverPresentationController class]) { // iOS8
avc.modalPresentationStyle = UIModalPresentationPopover;
UIPopoverPresentationController *ppc = avc.popoverPresentationController;
//ppc.permittedArrowDirections = UIPopoverArrowDirectionAny;
ppc.barButtonItem = self.shareButtonItem; // self.toolbarItems.lastObject;
//ppc.sourceRect = self.navigationController.toolbar.frame;
//ppc.sourceView = self.navigationController.toolbar;
} else {
self.myPopoverController = [[UIPopoverController alloc] initWithContentViewController:avc];
// self.myPopoverController.delegate = self;
[self.myPopoverController presentPopoverFromBarButtonItem:self.shareButtonItem permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
return;
}
}
[self presentViewController:avc animated:YES completion:nil];
@acalism
Copy link
Author

acalism commented Aug 27, 2015

适配ipad,iOS8下用popoverPresentationController实现,iOS7下用UIPopoverController实现

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