MFMailComposeViewController - iPad

前端 未结 5 1674
失恋的感觉
失恋的感觉 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 13:56

    Loos like MFMailComposeViewController was not created for some reason and thus has nil value. Check if it is nil before presenting it (although this workaround does not answer what went wrong here...).

    You should also perform the check if mail composer can send mail before trying to create and present it using +canSendMail method (it will return NO for example if no mail account set up on device):

     if ([MFMailComposeViewController canSendMail]){
        // Create and show composer
     }
     else{
       // Show some error message here
     }
    

提交回复
热议问题