ios - Why won't MFMailComposeViewController dismiss during in-app email? -


i working on ipad app creates pdf user emails in app. have been able setup email attach pdf, cannot mfmailcomposeviewcontroller dismiss. have read through several other questions on issue , attempted mimic doing, mail composer still not dismiss. need change in code dismiss?

- (ibaction)submitdailyreportbutton:(id)sender {  mfmailcomposeviewcontroller *mail = [[mfmailcomposeviewcontroller alloc]init]; [mail setmailcomposedelegate:self];  if ([mfmailcomposeviewcontroller cansendmail]) {      nsstring *email =@"admin@domain.com";     nsarray *emailarray = [[nsarray alloc]initwithobjects:email,nil];     [mail settorecipients:emailarray];      [mail setsubject:@"daily report"];      nsarray *paths = nssearchpathfordirectoriesindomains(nsdocumentdirectory, nsuserdomainmask, yes);      nsstring *newfilepath = [[paths objectatindex:0]stringbyappendingpathcomponent:@"report.pdf"];      nsdata *pdfdata = [nsdata datawithcontentsoffile:newfilepath];     [mail addattachmentdata:pdfdata mimetype:@"application/pdf" filename:@"report.pdf"];     nsstring *body = @"please review attached daily report";     [mail setmessagebody:body ishtml:no];     [mail setmodaltransitionstyle:uimodaltransitionstylecrossdissolve];     [self presentviewcontroller:mail animated:yes completion:nil];  }else{      nslog(@"message cannot sent");  } 

}

you have implement delegate method , dismiss view controller in delegate method.

- (void)mailcomposecontroller:(mfmailcomposeviewcontroller*)controller didfinishwithresult:(mfmailcomposeresult)result error:(nserror*)error {     [self dismissviewcontrolleranimated:yes completion:nil]; } 

side note - there no need create mail composer if can't send email. move allocation inside if statement.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -