Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set a mail Subject in UIActivityViewController?

I want to set subject for email sharing in UIActivityViewController and also want to share in Twitter. I know in Twitter if we want to share — we need compress text to 140 chars. I checked many SO solutions, but nothing is working.

Is this issue fixed in latest iOS releases? Any other "working solutions"?

like image 726
Femina Avatar asked Jun 10 '13 09:06

Femina


1 Answers

Check below code for the email for setting up 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 the line

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

Makes the subject as "Your email Subject" if user picks email option in the UIActivityViewController.

I hope it helps...

like image 72
emreoktem Avatar answered Sep 28 '22 02:09

emreoktem