How to set mail subject in UIActivityViewController?

I want to set a subject for email messaging in the UIActivityViewController , and also want to share on Twitter. I know on Twitter, if we want to share, we need to compress the text to 140 characters. I tested many SO solutions, but nothing works.

Is this issue fixed in recent versions of iOS? Any other "working solutions"?

+53
ios email objective-c uiactivityviewcontroller subject
Jun 10 '13 at 9:02
source share
3 answers

The emreoktem solution - setValue:forKey: in the UIActivityViewController - UIActivityViewController be undocumented.

In iOS 7 and later, you can implement the activityViewController:subjectForActivityType: method in an object that conforms to the UIActivityItemSource protocol to do this in a documented way.

+75
Oct 09 '13 at 18:31
source share

Sign an email code to customize your email subject:

 UIActivityViewController* avc = [[UIActivityViewController alloc] initWithActivityItems:@[@"Your String to share"] applicationActivities:nil]; [avc setValue:@"Your email Subject" forKey:@"subject"]; avc.completionHandler = ^(NSString *activityType, BOOL completed) { // ... }; 

Here is the line

[avc setValue: @ "Your email address Subject" forKey: @ "subject"];

Specifies the subject "Your question by email" if the user selects the email option in the UIActivityViewController.

Hope this helps ...

+85
01 Sep '13 at 22:38
source share

For Swift 2.0+ and ios 8.0 +

 let title = "Title of the post" let content = "Content of the post" let objectsToShare = [title, content] let activityVC = UIActivityViewController(activityItems: objectsToShare, applicationActivities: nil) activityVC.setValue(title, forKey: "Subject") self.presentViewController(activityVC, animated: true, completion: nil) 
+10
Mar 28 '16 at 9:02
source share



All Articles