Search code examples
iosobjective-cmfmailcomposeviewcontroller

MFMailComposeViewController cancel and send button not seen


I have tried to used MFMailComposeViewController but when the View is presented the cancel and send button is not seen. The VC comes in white color. I also tried to change some tint color of navigationBar but nothing worked. Device used iPhone 8

Any help in right direction would be helpful

Below is the code for the same.

MFMailComposeViewController *mailVC = [[MFMailComposeViewController alloc] init];

    mailVC.mailComposeDelegate = self;
    [mailVC setSubject:@"Looko App!"];
    [mailVC setMessageBody:@"Found and sent using Demo App!" isHTML:NO];

           [mailVC setToRecipients:@[@"[email protected]"]];

    [self presentViewController:mailVC animated:YES completion:nil];

the delegate callback is as below

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{

    switch (result) {
     case MFMailComposeResultSent:
        NSLog(@"Email sent");
        break;
    case MFMailComposeResultSaved:
        NSLog(@"Email saved");
        break;
    case MFMailComposeResultCancelled:
        NSLog(@"Email cancelled");
        break;
    case MFMailComposeResultFailed:
        NSLog(@"Email failed");
        break;
    default:
        NSLog(@"Error occured during email creation");
        break;
}

[self dismissViewControllerAnimated:YES completion:NULL];
}  

Solution

  • Try to setup the navigation bar appearance before initiating the MFMailComposeViewController:

    [UINavigationBar appearance].tintColor = [UIColor yourColor];
     MFMailComposeViewController *mailVC = [[MFMailComposeViewController alloc] init];
     //...