In the text of a UITextView, I have an email address, and the dataDetectorType is set to dataDetectorTypeLink. Is there any way to set the subject line of an email with this configuration? I know how to set the subject line of an email using an MFMailComposeController, but is there a way to combine that with dataDetectorType?

EDIT: Here's my (re)definition of `openURL:(NSURL *)url in my app delegate:

-(void)openURL:(NSURL *)url
{
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init];
    mailer.mailComposeDelegate = self;
    [mailer setSubject:@"feedback on Gay Haiku"];
    [self presentViewController:mailer animated:YES completion:NULL];
}

But I get an error No visible @interface for AppDelegate declares the selectorpresentViewController:animated:`.

有帮助吗?

解决方案

Did you try appending ?subject= to the link?

@"mailto:webmaster@site.com?subject=Web Site Extraordinaire"

I just realize could use that only if you switched to a UIWebView... Is that an option?

EDIT:

The other way is to subclass UIApplication and override openURL:. This is described here.

其他提示

Since this seems to be fixed text that you control, you can add a NSLinkAttributeName attribute to the NSAttributedString at the range of your email address instead of enabling automatic link detection. This will let you specify the full URL that you want the system to open when the link is tapped. Then you can use Mundi's suggestion (include subject= in the URL) to set the subject of the email.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top