我有以下代码,当调用操作表上的按钮时会调用该代码。但是,当我按取消,然后删除草稿时,它只是收费并且不会关闭。我在应用程序的其他地方使用相同的代码,并从选择的表格视图单元格中调用它,并且它可以在那里找到。有什么想法为什么它在这里不起作用吗?
当它冻结时,控制台中也没有错误消息。
if([MFMailComposeViewController canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Dr. Chrono Support"];
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSString* versionNum = [infoDict objectForKey:@"CFBundleVersion"];
NSString *appName = [infoDict objectForKey:@"CFBundleDisplayName"];
NSString *text = [NSString stringWithFormat:@"%@ %@",appName,versionNum];
// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected] /cdn-cgi/l/email-protection"];
//NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected] /cdn-cgi/l/email-protection", @"[email protected] /cdn-cgi/l/email-protection", nil];
//NSArray *bccRecipients = [NSArray arrayWithObject:@"[email protected] /cdn-cgi/l/email-protection"];
[picker setToRecipients:toRecipients];
//[picker setCcRecipients:ccRecipients];
//[picker setBccRecipients:bccRecipients];
// Attach an image to the email
//NSString *path = [[NSBundle mainBundle] pathForResource:@"rainy" ofType:@"png"];
//NSData *myData = [NSData dataWithContentsOfFile:path];
//[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"rainy"];
// Fill out the email body text
NSString *emailBody = text;
[picker setMessageBody:emailBody isHTML:NO];
[self presentModalViewController:picker animated:YES];
[picker release];
}
您需要实现委托方法:
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
然后在这个委托方法中添加:
[self dismissModalViewControllerAnimated:YES];
它应该工作得很好。
您不必寻找结果(仅当您想显示“谢谢”警报或其他内容时,例如,如果用户确实点击了“发送”)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)