gpt4 book ai didi

ios - 如何在 iOS 7 上使用 MFMailComposeViewController?

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

我正在为 iOS 7 开发应用程序并使用 MFMailComposerViewController

我已经尝试了所有方法,但 dismissViewController:withAnimated 不工作。

有时类在第一次显示 viewController 时使用方法 presentViewCONtroller:withAnimated:completion 自动调用自己的委托(delegate)。

我的应用是基于导航的,这就是为什么我认为问题也只与 UINavigationController 有关。

       -(void)sendMail{

if ([MFMailComposeViewController canSendMail]) {

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

[picker setSubject:@"Hello from California!"];

// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"];
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil];
NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"];

[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];
[picker setBccRecipients:bccRecipients];



// Fill out the email body text
NSMutableString *emailBody =[NSMutableString stringWithString: @"<table border=1 align=\"center\"><tr><th>EventDate</th><th>EventDay</th><th>EventTime</th><th>Speaker</th><th>topic</th></tr>"];

for (int i=0; i<5; i++) {
NSString *eventDate=[NSString stringWithFormat:@"<tr><td>%@</td>",@"12/11"];
NSString *eventDay=[NSString stringWithFormat:@"<td>%@</td>",@"Sunday"];
NSString *eventTime=[NSString stringWithFormat:@"<td>%@</td>",@"12:10 pm"];
NSString *eventSpeaker=[NSString stringWithFormat:@"<td>%@</td>",@"RajVeer"];
NSString *eventTopic=[NSString stringWithFormat:@"<td>%@</td>",@"nano-technology"];
NSString *dataString=[NSString stringWithFormat:@"%@%@%@%@%@</tr>",eventDate,eventDay,eventTime,eventSpeaker,eventTopic];
[emailBody appendString:dataString];
}
NSString *lastTable=@"</table>";
[emailBody appendString:lastTable];
NSLog(@"%@",emailBody);
[picker setMessageBody:emailBody isHTML:YES];

[self presentViewController:picker animated:YES completion:NULL];


}

最佳答案

这应该可以解决问题:

#pragma mark MFMailComposeViewControllerDelegate

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[controller dismissViewControllerAnimated:YES completion:nil];
}

关于ios - 如何在 iOS 7 上使用 MFMailComposeViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18978827/

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