EDIT
Customizing the MFMailComposeViewController
's appearance is a really bad idea and will most likely get your app rejected by Apple. The following solution should only be used if you don't intend to submit your app to Apple.
Looks like I solved it, thanks to Ray Wenderlich (again..). Here is the full code :
- (void)viewDidLoad
{
[super viewDidLoad];
[…] // Initializations
// Link detection
[_textView.attributedText addAttribute:NSLinkAttributeName value:@"mail://contact" range:[[content string] rangeOfString:@"contact@mymail.com"]];
_textView.delegate = self;
}
// Handle the link tap yourself
- (BOOL)textView:(UITextView *)textView shouldInteractWithURL:(NSURL *)URL inRange:(NSRange)characterRange {
if ([[URL scheme] isEqualToString:@"mail"]) {
MFMailComposeViewController *mailVC = [[MFMailComposeViewController alloc] init];
[mailVC setToRecipients:@[@"contact@ mymail.com"]];
[mailVC setSubject:@"About QuickReminder for iOS"];
mailVC.mailComposeDelegate = self;
// Re-set the styling
[mailVC.navigationBar setBarTintColor:myGreyColor];
[mailVC.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor], NSFontAttributeName: myFont}];
[mailVC.navigationBar setTintColor:[UIColor whiteColor]];
[self presentViewController:mailVC animated:YES completion:^{
[[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
}];
return NO;
}
return YES;
}
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
// Notifies users about errors associated with the interface
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Result: canceled");
break;
case MFMailComposeResultSaved:
NSLog(@"Result: saved");
break;
case MFMailComposeResultSent:
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Result" message:@"Mail Sent Successfully" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
[alert show];
}
break;
case MFMailComposeResultFailed:
NSLog(@"Result: failed");
break;
default:
NSLog(@"Result: not sent");
break;
}
[controller dismissViewControllerAnimated:YES completion:nil];
}