Question

Is it possible to override the activity that's performed by the built-in UIActivity types used by UIActivityViewController?

For example, I would like the Facebook activity to use my own custom view instead of the built-in one. I know you can subclass UIActivity to make your own app-specific activities, but are you always stuck with the default behavior for the built-in ones?

Was it helpful?

Solution

You can't override the built-in ones. The best you can do is deactivate them and replace them with your own subclasses of UIActivity. Functionally, this would have the same effect as overriding them.

Visually however this means that you have to provide your own icon images for these services. Apple's code will then take these images, throw away the colour data and use the alpha map to make a greyscale-tinted version set against Apple's usual black-dotted background. You can't provide colourful images for your own custom activities. Presumably this is to stop people from copying the 'official' service icons and subverting them for their own purposes, i.e. pretending to post something to Facebook while actually doing something quite different.

OTHER TIPS

You cannot override the behavior of the built-in UIActivity types - you can however override the data they get by providing your own UIActivityItemProvider subclass. For this you'll have to overide – activityViewController:itemForActivityType: So while it's not 100% what you're looking for you can at least bend the built-in ones a bit to your will.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top