gpt4 book ai didi

iphone - 如何使用 MFMailComposeViewController 设置收件人

转载 作者:太空狗 更新时间:2023-10-30 03:30:07 25 4
gpt4 key购买 nike

我正在尝试获取我选择发送电子邮件的电子邮件。但是我不知道如何设置我在 MFMailComposeViewController View 中选择的用户。

if ([MFMailComposeViewController canSendMail])
{
mailer = [[MFMailComposeViewController alloc] init];

mailer.mailComposeDelegate = self;
[mailer setSubject:@"A Message from blablabl"];

NSMutableArray *usersTo = [[NSMutableArray alloc] init];
toRecipients = usersTo;
[mailer setToRecipients:toRecipients];

NSString *emailBody = @"blablablabal";

[mailer setMessageBody:emailBody isHTML:YES];

// only for iPad
// mailer.modalPresentationStyle = UIModalPresentationPageSheet;

[self presentModalViewController:mailer animated:YES];
}
else
{
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure"
message:@"Your device doesn't support the composer sheet"
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles: nil];
[alert show];
}

代表 http://pastie.org/3281814

最佳答案

这里有一些错误。

1)

MFMailComposeViewController 的 setToRecipients方法需要一个已设置收件人的不可变数组。

2)

并且您将其设置为空白可变数组。

尝试这样的事情:

NSArray *usersTo = [NSArray arrayWithObject: @"nobody@stackoverflow.com"];
[mailer setToRecipients:usersTo];

你应该会看到它起作用了。

关于iphone - 如何使用 MFMailComposeViewController 设置收件人,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9063760/

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