gpt4 book ai didi

ios - 在 iOS 模拟器上模拟 MFMailComposeViewController。只需要显示 Composer

转载 作者:行者123 更新时间:2023-11-29 00:06:42 24 4
gpt4 key购买 nike

我只需要在我的 iOS 模拟器上显示电子邮件编辑器(无需发送实际邮件)。

当我初始化 MFMailComposeViewController 时,我收到警告弹出窗口,提示未设置电子邮件帐户。

这就是我正在做的。

MFMailComposeViewController* composeVC = [[MFMailComposeViewController alloc] init];

这一行弹出警报 Controller 。

最佳答案

对于模拟器电子邮件配置不可用。

使用下面的代码发送电子邮件。

- (void)openEmail
{
if ([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *mail =
[[MFMailComposeViewController alloc] init];
mail.mailComposeDelegate = self;
[mail setSubject:@"Subject"];
[mail setMessageBody:@"body message" isHTML:NO];
[mail setToRecipients:@[@"email1@example.com",@"email2@example.com"]];
/// if attachment then implement below line
//[mail addAttachmentData:<#(nonnull NSData *)#> mimeType:<#(nonnull NSString *)#> fileName:<#(nonnull NSString *)#>]
[self presentViewController:mail animated:YES completion:NULL];
}
else {
NSLog(@"Please configure your email. Settings->Accounts & Passwords->Add Account");
}
}

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(nullable NSError *)error
{
switch (result) {
case MFMailComposeResultSent:
NSLog(@"Sent");
break;
default:
break;
}
}

关于ios - 在 iOS 模拟器上模拟 MFMailComposeViewController。只需要显示 Composer ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47828052/

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