MFMailComposeViewController - iPad

前端 未结 5 1692
失恋的感觉
失恋的感觉 2020-12-28 13:46

I\'ve setup a MFMailComposeViewController and it works just fine on the iPhone, but on the iPad it crashes, saying:

*** Terminating app due to uncaught excep         


        
5条回答
  •  醉话见心
    2020-12-28 14:01

    You must have to put check canSendMail, before you create the MFMailComposerViewController object, see the following comments from MFMailComposeViewController.h class:

    /*!
    @method     canSendMail
    @abstract   Returns YES if the user has set up the device for sending email.
    @discussion The client may continue to set the recipients and content if the return value was YES.  If NO
                was the result, the client has a couple options.  It may choose to simply notify the user of the inability to
                send mail, or it may issue a "mailto" URL via -[UIApplication openURL:].
    */
    
    + (BOOL)canSendMail __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);
    

    Your object won't be initialized until your device is setup for sending mails.

提交回复
热议问题