Pregunta

With the new iOS 6, Apple added the new UIActivityViewController (image A) sharing menu which has little icon buttons to share instead of just the old UIActionSheet text button.

I want to display a UIActivityViewController but with custom buttons. I know they have a list of default applications that can displayed (Mail, Messages, Facebook, Twitter, etc...) but I want to customize what happens when you click on those buttons. When you click the Mail sharing icon it opens the Mail app with a new message, as an example i'd like it if when clicking on the Mail app, it opens the Twitter app (not really, but just something different than the default). Right now I can't seem to find a way to add my own methods behind the buttons.

With the latest ShareKit they added Instagram sharing and when you select to share with it a new view is displayed which looks exactly like the UIActivityViewController screen (image B). They seemed to have figured out how to add custom buttons that do custom things. I searched through the ShareKit code but can't seem to find where or how this is working out.

Maybe what i'm asking isn't even possible yet but any help is appreciated!

image Aimage A

image Bimage B

¿Fue útil?

Solución

Have look at this link. It's a pretty good introduction into sharing on iOS 6.

The following quote is from this blog post:

You can even add support for your own custom sharing options and still let UIActivityViewController handle the interaction with the user. To do that, subclass the abstract UIActivity class and override the required methods (see the documentation for details).

Otros consejos

Sharekit is an abstraction which is not customizable in the way you wish to use it. Apple controls the interface to these services.

Unfortunately, if you want to customize sharing and how it works, you will need to implement your own version of sharekit, with a UI and API entry points to these services.

Sharekit exists so that you dont have to do this. As needs change over time I expect Apple will add and remove services at will.

Using the API "as is" is your most sensible option.

I found this awesome tutorial. It works great,

Custom UIActivityViewcontroller

Image B is in fact using Instagrams Documentation Interaction code rather than a UIActivityViewController with a custom UIActivity. You can read more about Instagrams "hooks" here... custom iphone hooks

A UIActivity has been created by a 3rd party for Instagram which you can find here... This opens the same menu as ShareKit when selected as it is the only way to pass an image directly to Instagram.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top