gpt4 book ai didi

ios - MFMailComposeViewController 一直自动关闭

转载 作者:行者123 更新时间:2023-11-29 10:22:41 24 4
gpt4 key购买 nike

这是一个非常奇怪的问题!我在屏幕上有一个按钮,按下它会使用以下代码启动 MFMailComposeViewController:

-(IBAction) openComposeEmailScreen:(id) sender {

if([MFMailComposeViewController canSendMail]) {

MFMailComposeViewController *mailComposeViewController = [[MFMailComposeViewController alloc] init];
mailComposeViewController.mailComposeDelegate = self;

[mailComposeViewController setToRecipients:[NSArray arrayWithObject:@"johndoe@gmail.com"]];
[mailComposeViewController setSubject:@"HelloWorld"];

NSLog(@"%@",_pasteBoard.string);

[mailComposeViewController setMessageBody:_pasteBoard.string isHTML:NO];

[self presentViewController:mailComposeViewController animated:YES completion:nil];
}
}

-(void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {

if(error) {
NSLog(@"%@",error.localizedDescription);
}

[self dismissViewControllerAnimated:YES completion:nil];
}

此外,我的 View Controller 使用了正确的协议(protocol):

ViewController ()<MFMailComposeViewControllerDelegate>

我在模拟器上运行这个。

最佳答案

模拟器不支持

MFMailComposeViewController。您必须在设备上运行。

关于ios - MFMailComposeViewController 一直自动关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34076203/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com