gpt4 book ai didi

ios - dismissViewControllerAnimated : does not work

转载 作者:行者123 更新时间:2023-11-29 10:34:31 27 4
gpt4 key购买 nike

我有一种方法可以从我的 TableView 发送电子邮件。

所以其中一个单元格是“联系我们”单元格,每当它被点击时,我都会使用 MFMailComposeViewController 进入邮件 View Controller ,但问题是当我点击“取消”或“发送”我的邮件 View Controller 不会返回到 TableView 。 “取消”和“发送”操作有效,但我留在邮件 View Controller 上。

这是相关的方法:

- (void)sendEmail {
// Email Subject
NSString *emailTitle = @"Test Email";
// Email Content
NSString *messageBody = @"iOS programming is so fun!";
// To address
NSArray *toRecipents = [NSArray arrayWithObject:@"kkk@gmail.com"];

MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:toRecipents];

// Present mail view controller on screen
[self presentViewController:mc animated:YES completion:NULL];

}

- (void) mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Mail cancelled");

break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved");
break;
case MFMailComposeResultSent:
NSLog(@"Mail sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Mail sent failure: %@", [error localizedDescription]);
break;
default:
break;
}

// Close the Mail Interface
[self dismissViewControllerAnimated:YES completion:NULL];
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

SettingsControllerSection section = indexPath.section;

if (OtherControllerSection == section) {
SettingsControllerOtherSection row = indexPath.row;

switch (row) {

case RateUsController:
NSLog(@"rate us was pressed");
break;

case ContactUsControllerRow:
[self sendEmail];
NSLog(@"send email was pressed");
break;
}
}
}

请帮忙,谢谢!!

最佳答案

mailComposeController 方法中像这样关闭它:

[controller dismissViewControllerAnimated:YES completion:NULL];

关于ios - dismissViewControllerAnimated : does not work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27767244/

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