I had to decrypt all the UIActivityViewController documentation recently. You probably don't want to include UIImage with your NSURL in the blind hope that it will be used as a thumbnail. As far as I understand, you cannot be sure what UIActivity will do with the image, it can post this instead of the URL.
In your activityItems array parameter initWithActivityItems:applicationActivities: instead of NSURL pass the object you create that conforms to the UIActivityItemSource protocol. You can have any controller that opens a UIActivityViewController object that conforms to this protocol, for example, in this case your activityItems parameter will be @[self] .
In addition to implementing the 2 required methods, activityViewControllerPlaceholderItem: and activityViewController:itemForActivityType: in order to both simply return your NSURL and implement this to return any thumbnail that you like:
- (UIImage *)activityViewController:(UIActivityViewController *)activityViewController thumbnailImageForActivityType:(NSString *)activityType suggestedSize:(CGSize)size;
Pay attention to one thing that is not actually specified in the documentation, if you really need to have several objects in your activityItems array and update it to use UIActivityItemSource (or UIActivityItemProvider ) objects, then it needs a separate object to return each of source data objects in the source array. For example, if your data elements are NSURL and a UIImage , then make one UIActivityItemSource to return the NSURL and the other to return the UIImage . Having one UIActivityItemSource that returns an NSURL and UIImage , as your original activityItems array does not work.
source share