Don't I understand the UIActivityViewController, or is the implementation currently sucking?

I am trying to move my application to use a UIActivityViewController rather than a UIActionSheet, so that I get fancy graphic sharing buttons, not text buttons. (My app is only for iOS 6.)

Trying to work with him for a couple of nights, it seems that I do not completely understand how to use it, or the current Apple implementation is terrible:

  • You cannot specify a different message for different services. If I want something that will work through: Mail, Facebook, Messages AND Twitter, you will need a maximum of 140 characters to work on Twitter. Is there a way to set custom content for each activity?

  • It seems that it is not possible to set the subject line or recipient for mail messages. I read the documents, they sound like it could be possible using NSURL, which uses the mailto: protocol, but in my tests these URLs are simply inserted into the body of the message. Is there a way to set the subject line and, optionally, the recipients?

  • If I want to get around these shortcomings and perform my own actions by subclassing UIActivity, I have to use a custom image / icon. Therefore, I can not imitate Mail activity with the official Apple icon and, for example, implement my own activity backend, which actually allows me to set the subject, recipients, user authority, etc. I am mistaken, is there a way to use Apple service badges, but do you have the ability to customize the behavior? (The only callback I see is the one that starts AFTER the action completes, right?)

I hope I'm wrong!

+4
source share
2 answers

You are better off using a custom component that behaves like a UIAcitvityController , as it is rather limited, as you noted.

This is one example: https://github.com/hjnilsson/REActivityViewController , I just forked it from https://github.com/romaonthego/REActivityViewController so you can specify the email subject field.

+1
source

Is there a way to set custom content for each activity?

Yes, I think you should subclass UIActivityItemProvider and override the –activityViewController:itemForActivityType: method with your logic (e.g. crop a string to 140 characters for Twitter).
Then pass an instance of this class to -[UIActivityViewController initWithActivityItems:applicationActivities:] .


Is there a way to set the subject line and, optionally, the recipients?

You are right, the mailto scheme should be able to set these fields. If it does not work, I consider this a mistake. (I have not tried this myself, but I will give him a check.)


Is there a way to use Apple service badges, but do you have the ability to customize the behavior?

I think you can’t do this. (If you do not want to hack these system actions.)

+7
source

All Articles