7

In an iOS Share Extension it is possible to grab the preview image with loadPreviewImageWithOptions. Is it also possible to change the size of the preview image?

The preview image seems to be a screenshot of the website. I am wondering if it is possible to get the screenshot with the original size.

As documented a dictionary can be created for the options.

https://developer.apple.com/library/prerelease/ios/documentation/Foundation/Reference/NSItemProvider_Class/index.html#//apple_ref/doc/constant_group/Options_Dictionary_Key

For this reason I am using following code (trying with different values).

let options: [String: NSValue] = [NSItemProviderPreferredImageSizeKey: NSValue(CGSize: CGSizeMake(375.0, 600.0))]
itemProvider.loadPreviewImageWithOptions(options, completionHandler: { [ weak self ] image, error in
    if let image = image as? UIImage {
    }
})

But the result is always an image with the size of 84 x 79

Thanks!

rds
  • 133
  • 1
  • 4
  • Really long time since this was posted. But having the same issue. It always returns an image of size 210x210 for me, no matter what I ask for. – netdigger Jan 27 '20 at 21:14

0 Answers0