NSItemProvider loadItemForTypeIdentifier不遵守NSItemProviderPreferredImageSizeKey

时间:2017-10-09 19:35:24

标签: ios11 ios-app-extension ios8-share-extension share-extension

我正在尝试在我的应用扩展程序中获得最大1080x1080像素的调整大小的图像:

$List

但是,结果图像为NSExtensionItem *item = self.extensionContext.inputItems.firstObject; NSItemProvider *provider = item.attachments.firstObject; id imageOptions = @{ NSItemProviderPreferredImageSizeKey: [NSValue valueWithCGSize:CGSizeMake(1080, 1080)] }; if([provider hasItemConformingToTypeIdentifier:(NSString*)kUTTypeImage]){ [provider loadItemForTypeIdentifier:(NSString*)kUTTypeImage options:imageOptions completionHandler:^(id<NSSecureCoding> _Nullable item, NSError * _Null_unspecified error) { if(error){ NSLog(@"An error occured."); [self.extensionContext completeRequestReturningItems:nil completionHandler:nil]; }else{ NSURL *url = (NSURL*)item; UIImage *result = [UIImage imageWithData:[NSData dataWithContentsOfURL:url]]; //RESULT IS FULL SIZE HERE: 3024x4032 } }]; } 。我做错了什么?

0 个答案:

没有答案