MFMailComposeViewController not dismissing

前端 未结 5 867
名媛妹妹
名媛妹妹 2021-01-05 04:53

I have the following code that gets called in didSelectRowAtIndexPath. The issue is, when I click the cancel button, it prompts for save draft or discard. But when I click

5条回答
  •  刺人心
    刺人心 (楼主)
    2021-01-05 05:37

    There could be several problems:

    1. Not adding protocol implemantation in the .h

      @interface yourClass : UIViewController 
      
    2. Not adding the relevant function in .m:

      -(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:    (MFMailComposeResult)result error:(NSError*)error {
           [self dismissModalViewControllerAnimated:YES];
      }
      
    3. My error was not setting the correct delegate, but I fixed it :) and now it works for me:

       picker.mailComposeDelegate = self;
      

提交回复
热议问题