【问题标题】:issue using MFMailComposeViewController使用 MFMailComposeViewController 的问题
【发布时间】:2012-04-27 07:33:40
【问题描述】:

我在使用 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];     
  });
}

谢谢

【问题讨论】:

    标签: iphone objective-c ios mfmailcomposeviewcontroller


    【解决方案1】:

    给你!

    -(IBAction)email {
        MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init];
        [composer setMailComposeDelegate:self];
        if ([MFMailComposeViewController canSendMail]) {
            [composer setToRecipients:[NSArray arrayWithObjects:@"", nil]];
            [composer setSubject:@""];
            [composer setMessageBody:@"" isHTML:NO];
            [composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve];
            [self presentModalViewController:composer animated:YES];
            [composer release];
        }
        else
            [composer release];
    }
    

    【讨论】:

    • 这不能回答问题。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多