This question already has an answer here:
Hope everyone is aware of iOS 6 contains new style of ActionSheet (UIActivityViewController).
The UIActivityViewController
can be initiated with the paramentes like string, url, image etc. Below is the code snippet for that (where items is an array with string and url params).
UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil];
But, is there any way that we can assign different parameters when we select different share options like Mail, Facebook or Twitter?
One method is we can implement UIActivityItemSource, where we need to implement the source methods
- (id)activityViewController:(UIActivityViewController *)activityViewController itemForActivityType:(NSString *)activityType
which always returns a string value. But I need to pass an Array, so that I can assign various parameters like URL, image and a title.
Any idea how we can achieve this?
You can not change anything for the built in iOS UIActivityViewController items like Mail, Facebook and Twitter. In order to implement custom actions for items in your UIActivityViewController you must create a custom subclass of UIActivity for each custom activity you want. Here is an example:
A very limited example of a subclassed UIActivity with documentation on the methods that you will be interested in overriding to handle your custom data/actions.