How to share items with a UIActivityViewController

Another option to share items in your app is to bring up a dialogue that contains several options, like the Photos app does:

Screen Shot 2013-12-06 at 18.54.19

This is done with a UIActivityViewController and requires minimal work on our part. This controller is very clever and only brings up relevant services (you can’t print a video, or you can’t share a video to Twitter, so those options don’t appear in the list).

Here’s how we use it:

UIActivityViewController does not require any frameworks to be imported into your class. The items array can take anything from text, pictures or video (just not mixed together). If an item is not setup the icon won’t appear in the list.

You can specify which items to exclude from the list by defining an array of UIActivities, and you can specify a completion block.

About Jay Versluis

Jay is a medical miracle known as a Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Add your voice!