Search code examples
objective-ciosuitextfielddatadetectortypes

How to set email subject from dataDetectorTypeLink?


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


Solution

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