cant dismiss MFMailComposeViewController shown by clicking mail link in UITextVIew (iOS 8 beta bug)

二次信任 提交于 2019-12-11 08:24:53

问题


This turned out to be due to bug in iOS 8 beta. I have reported it via bug number 17318153

I'm setting an email address to a UITextField. The intent is for iOS to see its an email address and, if the user taps it, display an instance of MFMailComposeViewController to send an email (which it does).

However, if the user then taps cancel, the MFMailComposeViewController is not being dismissed. I tried setting my viewController as a MFMailComposeViewControllerDelegate and overriding mailComposeController: didFinishWithResult: error: but it's not being called. Seemingly, the delegate for the MFMailComposeViewController that is displayed when the url is tapped is not set to self.

How can I make the cancel button in the MFMailComposeViewController actually dismiss the view controller that is displayed?

My .h:

#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>

@interface AboutUsViewController : UIViewController<MFMailComposeViewControllerDelegate>{

    IBOutlet UIImageView *imageView;
    IBOutlet UITextView *companyName;
    IBOutlet UITextView *phoneNumber;
    IBOutlet UITextView *emailAddress;
    IBOutlet UITextView *aboutUsField;

}
@end

In .m:

- (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        emailAddress.text=@"support@email.com";
}



- (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];
}

回答1:


This is a known iOS8 beta 1 issue. Make sure to open a bug report with Apple and post the bug report number here so people can duplicate.



来源:https://stackoverflow.com/questions/24218708/cant-dismiss-mfmailcomposeviewcontroller-shown-by-clicking-mail-link-in-uitextvi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!