MFMailComposeViewController throws a viewServiceDidTerminateWithError and then exits when using a custom title font

Setting a custom font for the UITextAttributeFont to the titleTestAttributes of the UINavigationBar appearance proxy causes the bug as the OP and MightlyLeader identified.

Workaround Code:

// remove the custom nav bar font
NSMutableDictionary* navBarTitleAttributes = [[UINavigationBar appearance] titleTextAttributes].mutableCopy;
UIFont* navBarTitleFont = navBarTitleAttributes[UITextAttributeFont];
navBarTitleAttributes[UITextAttributeFont] = [UIFont systemFontOfSize:navBarTitleFont.pointSize];
[[UINavigationBar appearance] setTitleTextAttributes:navBarTitleAttributes];

// set up and present the MFMailComposeViewController
MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init];
mailComposer.mailComposeDelegate = self;
[mailComposer setSubject:emailInfo[@"subject"]];
[mailComposer setMessageBody:emailInfo[@"message"] isHTML:YES];
mailComposer.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:mailComposer animated:YES completion:^{

    // add the custom navbar font back
    navBarTitleAttributes[UITextAttributeFont] = navBarTitleFont;
    [[UINavigationBar appearance] setTitleTextAttributes:navBarTitleAttributes];
}];

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)