Skip to content

Commit

Permalink
Default share options are displayed in a popover on iPad.
Browse files Browse the repository at this point in the history
  • Loading branch information
heikkihautala committed May 13, 2015
1 parent c0257a8 commit a491d10
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions Pod/Classes/ios/NYTPhotosViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ @interface NYTPhotosViewController () <UIPageViewControllerDataSource, UIPageVie
@property (nonatomic) id <NYTPhotosViewControllerDataSource> dataSource;
@property (nonatomic) UIPageViewController *pageViewController;
@property (nonatomic) NYTPhotoTransitionController *transitionController;
@property (nonatomic) UIPopoverController *activityPopoverController;

@property (nonatomic) UIPanGestureRecognizer *panGestureRecognizer;
@property (nonatomic) UITapGestureRecognizer *singleTapGestureRecognizer;
Expand Down Expand Up @@ -239,8 +240,29 @@ - (void)actionButtonTapped:(id)sender {
[self.delegate photosViewController:self actionCompletedWithActivityType:activityType];
}
};

[self presentViewController:activityViewController animated:YES completion:nil];

[self displayActivityViewController:activityViewController animated:YES];
}
}

- (void)displayActivityViewController:(UIActivityViewController *)controller animated:(BOOL)animated {

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) {
[self presentViewController:controller animated:animated completion:nil];
}
else {
if ([controller respondsToSelector:@selector(popoverPresentationController)]) {

// iOS8 and above
controller.popoverPresentationController.barButtonItem = self.rightBarButtonItem;
[self presentViewController:controller animated:animated completion:nil];
}
else {
self.activityPopoverController = [[UIPopoverController alloc] initWithContentViewController:controller];
[self.activityPopoverController presentPopoverFromBarButtonItem:self.rightBarButtonItem
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:animated];
}
}
}

Expand Down

0 comments on commit a491d10

Please sign in to comment.