我正在尝试在我的应用扩展程序中获得最大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
}
}];
}
。我做错了什么?