Category

UIActivityViewController in Swift

Swift Language

Just a simple example of using the UIActivityViewController in Swift.

You need to be logged into Facebook and Twitter for the options to share to them shows up. You can do this in the simulator by going to the settings app. If you do not log in, then you will just see Mail and Copy as options.

Set up

All that is needed is to instantiate UIActivityViewController with the item[s] to share, then present it. Here is a simple example:

You can specify that there are sharing options that you do not want like this. This is all of them, so in real life you wouldn’t want to exclude them all.

If you want to do something upon completion, install a handler like this:

Download the project from this Github repository.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.