Post

Replies

Boosts

Views

Activity

Providing a different type for the placeholder item and the true item in UIActivityItemSource/Provider
I'm writing an app where I would like to provide a list of PDF documents to a UIActivityViewController. I read in the docs for UIActivityItemSource that I can do the following:> This method returns an object that can be used as a placeholder for the real data. Placeholder objects do not have to contain any real data but should be configured as closely as possible to the actual data object you intend to provide. In general the actual value should match in type but it is possible to return a different type of data for activityViewController(_:itemForActivityType:). It should be one that the activity can handle otherwise you may get an activity with empty content. For example, the placeholder could be a UIImageobject but the actual value could be an NSData object with PDF information.https://developer.apple.com/documentation/uikit/uiactivityitemsource/1620458-activityviewcontrollerplaceholdeHowever, when I do exactly that, and pass a UIImage, the activities that are suggested are UIImage based activities, not PDF ones even though I am specifying the PDF UTI for every activity type. If I specify the data for a PDF document with only the first page of the document I would like to export, I don't get any UIImage suggestions but I also don't get PDF specific suggestions. The only thing that seems to work is providing a URL to a PDF for the placeholder and a URL or Data for the item.
0
0
419
May ’20