问题
On iOS 6, after sending a few email messages (by using MFMailComposeViewController), the email screens become very slow to open- at first opening with none of the fields populated (no Subject, no body, etc.) for a few seconds, and eventually (after sending about 8 messages), a black screen is displayed to the user for a few seconds before the email view controller is properly displayed.
The log spits out the following line before each black screen is displayed:
[MFMailComposeRemoteViewController: ....] timed out waiting for fence barrier from com.apple.MailCompositionService
Also, using MFMailComposeViewController on iOS6 causes the MailCompositionS process to start hogging memory (it's going all the way up to roughly 260MB on my iPhone). I'm assuming this is the reason for the MFMailComposeViewController display issues.
Everything runs fine on iOS 5. This issue only occurs on iOS 6.
Has anyone found a way to resolve this issue?
Thanks!
The code is standard, but I'll include it anyway:
-(IBAction)doEmailLog:(id)sender
{
if( [self canSendMail] )
{
// create the compose message view controller
MFMailComposeViewController* mailComposer = [[MFMailComposeViewController alloc] init];
// this class will handle the cancel / send results
mailComposer.mailComposeDelegate = self;
// fill in the header and body
[mailComposer setSubject:@"My Subject"];
[mailComposer setMessageBody:@"My message body" isHTML:NO];
// attach log file
if ([[NSFileManager defaultManager] fileExistsAtPath:filename])
{
NSData *data = [NSData dataWithContentsOfFile:filename];
[mailComposer addAttachmentData:data mimeType:@"text/plain" fileName:filename];
}
// show the view controller
[self presentViewController:mailComposer animated:YES completion:^{LogTrace(@"Presented mail view controller");}];
}
else
{
...
}
}
-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
...
// dismiss the compose message view controller
[self dismissViewControllerAnimated:YES completion:^{LogTrace(@"Finished dismissing mail controller");}];
}
回答1:
on ios 6 the mail composer is its own app (inside yours) :: http://oleb.net/blog/2012/10/remote-view-controllers-in-ios-6/
the code looks good to me if you are using ARC else it leaks and on ios6 that might result in x XPC remotes
if all is good there, Id blame it on a bug in apple's new handling of XPC
回答2:
there's another possible solution:
Remove custom fonts from the appearance methods, if you have any
https://stackoverflow.com/a/19910337/104170
来源:https://stackoverflow.com/questions/13298448/ios6-mfmailcomposeviewcontroller-slow-to-load-and-flashes-black-screen-mailcom