How to set a mail Subject in UIActivityViewController?

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...


It seems as though emreoktem's solution—sending setValue:forKey: to the UIActivityViewController—is undocumented.

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