我在使用 MFMailComposeViewController 时遇到问题。这是我尝试在设备上运行的示例代码。我故意添加了 5 秒的延迟(只是为了模拟下载附件文件的体验),之后应用程序会显示“邮件”控制器。在延迟期间,如果我们单击主页按钮,即让应用程序在后台运行并在 5 秒前恢复应用程序,主题字段将为空白,并且消息正文将具有值“消息 1”而不是“消息 2” " 如果我们最小化应用程序并在 5 秒后恢复应用程序,主题不会出现,但正文将是 "message2" 而不是 "message 1"。你能帮我理解这种行为吗?
-(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];
});
}
谢谢