注意到我用来模态弹出对话框以发送电子邮件的 MFMailComposeViewController 在 iOS6 中不再有效。它仍然会弹出对话框,但我无法设置正文,或在视图中输入任何内容。我所能做的就是按取消。
该类实现了 MFMailComposeViewControllerDelegate 接口,下面是一些代码:
//h file
@interface ASEmailSender : NSObject
//m file
@implementation MyEmailSender () <MFMailComposeViewControllerDelegate>
@end
@implementation MyEmailSender
...
- (void)emailFile:(ASFile *)file inController:(UIViewController *)viewController {
MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
if ([MFMailComposeViewController canSendMail]) {
mailController.mailComposeDelegate = self;
[mailController setSubject:@"my subject"];
[mailController setMessageBody:@"msg body here" isHTML:NO];
[viewController showIsLoading:YES];
self.viewController = viewController
[viewController presentModalViewController:mailController animated:YES];
}
}
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
[self.viewController dismissModalViewControllerAnimated:YES];
}
它在 iOS5 中运行良好。