diff --git a/CHANGELOG.md b/CHANGELOG.md index ae2c2fdc..a727980a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,10 @@ Changes for users of the library in 2.0.0: - A data source no longer has to handle out-of-bounds indexes ([#227](https://github.com/NYTimes/NYTPhotoViewer/pull/227)) - The data source is not retained ([#227](https://github.com/NYTimes/NYTPhotoViewer/pull/227)) - Respect safe areas for iOS 11 support +- Fixed some tests, added tests for NYTPhotoViewerSinglePhotoDataSource +- Fixed a strict warning and a subscripting bug in NYTPhotoViewerArrayDataSource.m +- Share GIF with UIActivityViewController +- Copy GIF with UIMenuController ## [1.2.0](https://github.com/NYTimes/NYTPhotoViewer/releases/tag/1.2.0) diff --git a/NYTPhotoViewer/NYTPhotosViewController.m b/NYTPhotoViewer/NYTPhotosViewController.m index e089d081..d5d37a02 100644 --- a/NYTPhotoViewer/NYTPhotosViewController.m +++ b/NYTPhotoViewer/NYTPhotosViewController.m @@ -17,6 +17,7 @@ #import "NYTPhotosOverlayView.h" #import "NYTPhotoCaptionView.h" #import "NSBundle+NYTPhotoViewer.h" +#import #ifdef ANIMATED_GIF_SUPPORT #import @@ -70,7 +71,12 @@ - (void)dealloc { #pragma mark - NSObject(UIResponderStandardEditActions) - (void)copy:(id)sender { - [[UIPasteboard generalPasteboard] setImage:self.currentlyDisplayedPhoto.image]; + UIPasteboard *pasteboard = [UIPasteboard generalPasteboard]; + if (self.currentlyDisplayedPhoto.image) { + [pasteboard setImage:self.currentlyDisplayedPhoto.image]; + } else { + [pasteboard setData:self.currentlyDisplayedPhoto.imageData forPasteboardType:(NSString *) kUTTypeGIF]; + } } #pragma mark - UIResponder @@ -80,7 +86,9 @@ - (BOOL)canBecomeFirstResponder { } - (BOOL)canPerformAction:(SEL)action withSender:(id)sender { - if (self.shouldHandleLongPress && action == @selector(copy:) && self.currentlyDisplayedPhoto.image) { + BOOL containsImage = self.currentlyDisplayedPhoto.image || self.currentlyDisplayedPhoto.imageData; + + if (self.shouldHandleLongPress && action == @selector(copy:) && containsImage) { return YES; } @@ -290,7 +298,7 @@ - (void)actionButtonTapped:(id)sender { } if (!clientDidHandle && (self.currentlyDisplayedPhoto.image || self.currentlyDisplayedPhoto.imageData)) { - UIImage *image = self.currentlyDisplayedPhoto.image ? self.currentlyDisplayedPhoto.image : [UIImage imageWithData:self.currentlyDisplayedPhoto.imageData]; + NSData *image = self.currentlyDisplayedPhoto.image ? UIImagePNGRepresentation(self.currentlyDisplayedPhoto.image) : self.currentlyDisplayedPhoto.imageData; UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[image] applicationActivities:nil]; activityViewController.popoverPresentationController.barButtonItem = sender; activityViewController.completionWithItemsHandler = ^(NSString * __nullable activityType, BOOL completed, NSArray * __nullable returnedItems, NSError * __nullable activityError) {