I am having a problem using MFMailComposeViewController. Here is an example of the code I tried to run on the device. I intentionally added a delay of 5 seconds (just to simulate the experience of downloading a file for attachment), after which the application is a "mail" controller. During the delay, if we press the home button, that is, we will make the application launch in the background and resume the application for up to 5 seconds, the subject field will be empty, and the message body will have the value “message 1” rather than “message 2” "and if we hide the application and resume it after 5 seconds, the subject will not appear, but the body will be" message2 ", not" message 1. "Could you help me understand the behavior.
-(void) func:(MFMailComposeViewController *) mail
{
[mail setMessageBody:@"message 2" isHTML:NO];
[self presentModalViewController:mail animated:YES];
}
- (IBAction)action:(id)sender
{
MFMailComposeViewController * mail = [[MFMailComposeViewController alloc] init];
[mail setMailComposeDelegate:self];
[mail setMessageBody:@"message 1" isHTML:NO];
[mail setSubject:@"subject 1"];
dispatch_async(dispatch_get_main_queue(), ^{
[self performSelector:@selector(func:) withObject:mail afterDelay:5];
});
}