4

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

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

        }
    }];
}

但是,结果图像是3024x4032. 我究竟做错了什么?

4

0 回答 0