IOS UIActivityItemProvider user interface exchanges image and text

I have subclassed UIActivityItemProvider to be able to choose what to do if the user selects Facebook or Twitter or Mail, etc. But I can only use text or an image in a function element - (id), I don’t know how to share both text and image, for example.

If I read the tutorials, I know how to do this for all sharing options, but I don't want all sharing options to have an image or link or text:

NSArray* dataToShare = @[someText, [NSURL URLWithString:url], image]; UIActivityViewController* activityViewController = [[UIActivityViewController alloc] initWithActivityItems:dataToShare applicationActivities:nil]; 
+6
source share
1 answer

Found

 CustomActivityItemProvider *itemProvider = [[CustomActivityItemProvider alloc] init]; UIActivityViewController* activityViewController = [[UIActivityViewController alloc] initWithActivityItems:@[itemProvider, image] applicationActivities:nil]; 

This will use my CustomActivityItemProvider, where I will select the text, and the image will be used if the sharing option is selected (facebook, twitter, etc.)

+7
source

Source: https://habr.com/ru/post/977465/


All Articles