mirror of
https://github.com/oxen-io/session-ios.git
synced 2023-12-13 21:30:14 +01:00
Copy images to pasteboard as data, not UIImage.
// FREEBIE
This commit is contained in:
parent
7a7cc34cdd
commit
86abb43c30
|
@ -7,6 +7,7 @@
|
|||
#import "JSQMediaItem+OWS.h"
|
||||
#import "TSAttachmentStream.h"
|
||||
#import <JSQMessagesViewController/JSQMessagesMediaViewBubbleImageMasker.h>
|
||||
#import <MobileCoreServices/MobileCoreServices.h>
|
||||
|
||||
@interface TSPhotoAdapter ()
|
||||
|
||||
|
@ -112,7 +113,18 @@
|
|||
}
|
||||
|
||||
if (action == @selector(copy:)) {
|
||||
UIPasteboard.generalPasteboard.image = self.image;
|
||||
OWSAssert(self.attachment.filePath.length > 0);
|
||||
NSString *fileExtension = [self.attachment.filePath pathExtension];
|
||||
NSArray *utiTypes = (__bridge_transfer NSArray *)UTTypeCreateAllIdentifiersForTag(
|
||||
kUTTagClassFilenameExtension, (__bridge CFStringRef)fileExtension, (CFStringRef) @"public.image");
|
||||
NSString *utiType = (NSString *)kUTTypeImage;
|
||||
OWSAssert(utiTypes.count > 0);
|
||||
if (utiTypes.count > 0) {
|
||||
utiType = utiTypes[0];
|
||||
}
|
||||
|
||||
NSData *data = [NSData dataWithContentsOfURL:self.attachment.mediaURL];
|
||||
[UIPasteboard.generalPasteboard setData:data forPasteboardType:utiType];
|
||||
return;
|
||||
} else if (action == NSSelectorFromString(@"save:")) {
|
||||
UIImageWriteToSavedPhotosAlbum(self.image, nil, nil, nil);
|
||||
|
|
Loading…
Reference in a new issue