How can I create a custom UIActivity
in iOS?
The reason I want this is to add a Review App button in one of my apps that takes the user to the review section in the App Store. How can I create such a custom UIActivity
?
How can I create a custom UIActivity
in iOS?
The reason I want this is to add a Review App button in one of my apps that takes the user to the review section in the App Store. How can I create such a custom UIActivity
?
Here's an example of putting up an email composer interface using the -activityViewController method of UIActivity. This shows how to put up a UIKit viewController or your own custom viewController for whatever purpose you choose. It supplants the -performActivity method.
Notice that -activityDidFinish is called from the mail composer delegate after the user has dismissed the email interface. This is required to get the UIActivityViewController interface to disappear. If you write your own viewController it will need a delegate method that it calls when finished and you will have to make your subclass of UIActivity the delegate.
First, create the files. I chose to name mine ActivityViewCustomActivity
Make ActivityViewCustomActivity.h look like this:
Make ActivityViewCustomActivity.m look like this:
This is what my image looked like: Here is the .PSD I made: -- malicious link removed -- And here is the original 250 px .png http://i.imgur.com/pGWVj.png
Now in your view controller do this:
And now wherever you want to display your
UIActivityViewController
:Here is my Swift Version - I needed multiple custom actions so I created this class. No need for delegates or protocols.
1. Add the custom Class
2 Use in your View Controller
I've attached it to a UIBarButtonItem, which calls the the following
My Swift 3 Implementation based off of DogCoffee's: