Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Override activity performed by built-in UIActivity types

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?

like image 947
SeanK Avatar asked Jan 07 '13 22:01

SeanK


2 Answers

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.

like image 142
Ash Avatar answered Oct 21 '22 01:10

Ash


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.

like image 41
Matthias Wenz Avatar answered Oct 21 '22 01:10

Matthias Wenz