Airdrop: how do I avoid my thumbnail image having borders to left and right of image?

StackOverflow https://stackoverflow.com/questions/20241552

  •  05-08-2022
  •  | 
  •  

I'm experimenting with Airdrop and sending a thumbnail preview image.

The receiving device shows the preview thumbnail image in the receive confirm dialog, but often the image is downsized so that there is blank space in the Airdrop receive dialog to the left and right of the thumbnail. I want to get rid of this horizontal border.

The Airdrop receive dialog is 540 pixels wide. If I send a thumbnail that is 540 pixels wide and <= 400 pixels high, there is no horizontal border. If I send a square 540 x 540 image, I get the horizontal border. And yet when you send an image from Camera roll using Airdrop, no horizontal border appears around the thumbnail in the receive dialog, despite the thumbnail being >400 pixels high.

有帮助吗?

解决方案

I would recommend using the UIActivityItemSource to provide metadata (such as the preview photo).

When the UIActivityViewController machinery requests the preview photo using the UIActivityItemSource's method activityViewController:thumbnailImageForActivityType:suggestedSize: it will pass in a CGSize that you should make sure your image fits inside. Make sure to adjust the dimensions of the image to fit the suggestedSize if you want it to fill up the full width of the alert. See the AirDrop sample code for an example of how to do this.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top