-1

Possible Duplicate:
UIActivityViewController - Email and Twitter sharing

I'm starting to get familiar with the new iOS 6 way to share: UIActivityViewController (the same as when you share a photo from the native iOS photo app), but I'm experiencing a few problems. First, when I choose to share via email, I can't find a way to set the subject of the email. Second, when I post on twitter, I can't find how to post a URL (except explicitly writing it in a NSString).

Before, on iOS 5, I was using MFMailComposeViewController for Mail and SLComposeViewController for Twitter. It worked well. If there's no way to choose the subject with UIActivityViewController, could there be a way that I put my own custom buttons on the ActivityViewController, buttons that will call MFMailComposeViewController and SLComposeViewController when touched? I'm just speculating here.

Thanks!

Community
  • 1
  • 1
anthoprotic
  • 827
  • 2
  • 13
  • 24
  • For the URL just put `NSURL` object in activity items array. I don't know how to add the subject to the e-mail :) – Fahri Azimov Oct 19 '12 at 06:04
  • Then, do you know if it's possible to do a custom button with mail's icon that when pressed goes to my same IBAction as in iOS 5 when I used MFMailComposeViewController and set the subject? – anthoprotic Oct 19 '12 at 13:10
  • I've **[answered][1]** this in another question you have posted. [1]: http://stackoverflow.com/questions/12984403/uiactivityviewcontroller-email-and-twitter-sharing/12984541#12984541 – runmad Oct 20 '12 at 01:49

1 Answers1

-1

I've answered this in another question you have posted.

NSString *text = @"My mail text";

NSURL *recipients = [NSURL URLWithString:@"mailto:me@example.com?subject=Hi"];

NSArray *activityItems = @[text, recipients];

UIActivityViewController *activityController = [[UIActivityViewController alloc]
                                            initWithActivityItems:activityItems 
                                            applicationActivities:nil];

[self presentViewController:activityController animated:YES completion:nil];
Community
  • 1
  • 1
runmad
  • 14,846
  • 9
  • 99
  • 140
  • @BryanH the code already had an array. It uses the new Container Literals for NSArrays, etc. `@[]`. You can read more here: http://clang.llvm.org/docs/ObjectiveCLiterals.html – runmad Oct 30 '12 at 12:50
  • Thanks! I initially pasted that line with the literals into a project and got an error, so I assumed it was incorrect. It turns out that project was using an older LLVM. Bumping up the version made the error go away. – BryanH Oct 30 '12 at 13:32