我在ios6中的MFMailComposeViewController不再起作用



注意到,我用来将我的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中效果很好。

我通过更改myemailsender为uiviewController而不是nsobject来解决此问题。由于某种原因,这在iOS6中运行时会解决问题。新代码看起来像:

//h file
@interface ASEmailSender : UIViewController <MFMailComposeViewControllerDelegate>

//m file
@implementation MyEmailSender
...
(same functions as before)

现在它在ios5和ios6中都起作用。

我解决了完全相同的问题(在ios6:空白作曲家屏幕中,只有取消按钮可行。而在ios5中,相同的代码可以正常工作。)

我确实导入了:

#import <MessageUI/MFMailComposeViewController.h>

但我忘记了这个:

#import <MessageUI/MessageUI.h>

添加MessageUi.H的导入后,iOS 6上没有更多问题。

最新更新