Reputation: 4994
I am trying to export an image vi UIActivityViewController
I was wondering how can add more application like Instagram or other photo editing apps ?
- (IBAction)share:(id)sender {
NSArray* dataToShare = @[_image.image];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:dataToShare
applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:nil];
}
Upvotes: 2
Views: 4024
Reputation: 690
Check out this blog post.
In short, you have to subclass UIActivity for each of the additional app you want to present in your activity view controller and pass their instances as an NSArray for parameter applicationActivities:
.
An excerpt from Apple documentation concerning UIActivity subclasses:
Subclassing Notes
This class must be subclassed before it can be used. The job of an activity object is to act on the data provided to it and to provide some meta information that iOS can display to the user. For more complex services, an activity object can also display a custom user interface and use it to gather additional information from the user.
Methods to Override
When subclassing, you must always override the following methods and use them to provide information about your service:
activityType
activityTitle
activityImage
canPerformWithActivityItems:
prepareWithActivityItems:
Upvotes: 1
Reputation: 318934
You need to make use of the applicationActivities
parameter and pass in any additional, custom activities.
What I do in one of my apps is to create a single "Open In" custom UIActivity
. If the user selects that activity, I then use UIDocumentInteractionController
to show the standard "open in" menu. This allows iOS to display any apps that can open the image.
Another option is you could add multiple custom activities, one for each specific app you wish to support.
Shortly after iOS 6.0 came out I submitted an enhancement request to Apple to directly support "Open In" type functionality in an activity view.
Upvotes: 3