Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 28 nytphotosviewcontroller crashes on tapping share button on ipad #52

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 30 additions & 3 deletions Example/NYTPhotoViewer/Base.lproj/Main_iPad.storyboard
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="5023" systemVersion="13A603" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" initialViewController="BYZ-38-t0r">
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7702" systemVersion="14C109" targetRuntime="iOS.CocoaTouch.iPad" propertyAccessControl="none" useAutolayout="YES" initialViewController="BYZ-38-t0r">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="3733"/>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7701"/>
<capability name="Aspect ratio constraints" minToolsVersion="5.1"/>
</dependencies>
<scenes>
<!--class Prefix:identifier View Controller-->
<!--View Controller-->
<scene sceneID="tne-QT-ifu">
<objects>
<viewController id="BYZ-38-t0r" customClass="NYTViewController" sceneMemberID="viewController">
Expand All @@ -15,13 +17,38 @@
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
<rect key="frame" x="0.0" y="0.0" width="768" height="1024"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleAspectFit" contentHorizontalAlignment="center" contentVerticalAlignment="center" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="iq7-HY-cl8" userLabel="ImageButton">
<rect key="frame" x="234" y="411" width="300" height="203"/>
<constraints>
<constraint firstAttribute="width" constant="300" id="nTW-df-zCq"/>
<constraint firstAttribute="width" secondItem="iq7-HY-cl8" secondAttribute="height" multiplier="80:54" id="qro-x0-xtJ"/>
</constraints>
<state key="normal" image="NYTimesBuilding">
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
</state>
<connections>
<action selector="imageButtonTapped:" destination="BYZ-38-t0r" eventType="touchUpInside" id="BYt-BH-9R9"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
<constraints>
<constraint firstAttribute="centerX" secondItem="iq7-HY-cl8" secondAttribute="centerX" id="Elg-6Y-pFJ"/>
<constraint firstAttribute="centerY" secondItem="iq7-HY-cl8" secondAttribute="centerY" id="IYU-vQ-nkL"/>
</constraints>
</view>
<connections>
<outlet property="imageButton" destination="iq7-HY-cl8" id="1BO-Wt-P5z"/>
</connections>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
</objects>
</scene>
</scenes>
<resources>
<image name="NYTimesBuilding" width="800" height="540"/>
</resources>
<simulatedMetricsContainer key="defaultSimulatedMetrics">
<simulatedStatusBarMetrics key="statusBar"/>
<simulatedOrientationMetrics key="orientation"/>
Expand Down
24 changes: 22 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,27 @@ - (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)]) {
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