2013-06-01 44 views
-1

我正在從iPhone應用程序發送電子郵件我想當用戶點擊發送電子郵件按鈕後,它應該調用測試()方法任何想法如何做到這一點我正在使用以下代碼。發送按鈕後如何調用方法發送電子郵件從iphone應用程序點擊

NSString * emailBody [email protected]"<html><body>Thank you for your participation in Consulting<br>Practitioner and Client Program.</br><br>Attached is the copy of your signed contract for your records<p>Please email or fax your completed W-9 form to<br>our PEI Support Team<br>Email:[email protected]<br>Fax:800-741-1310<body></html>"; 



[picker setMessageBody:emailBody isHTML:YES]; 





[self.navigationController presentViewController:picker animated:YES completion:nil]; 




} 

} 


[self test];  

}

+0

test() - 方法..在這個意義上..?你需要郵件確認或你自己的方法..? –

回答

0

請儘量implemente此委託方法?這是在用戶退出作曲家之後調用的。

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error { 
    NSString *message = @""; 
    // Notifies users about errors associated with the interface 
    switch (result) { 
     case MFMailComposeResultCancelled: 
      message = @"Mail: canceled"; 
      break; 
     case MFMailComposeResultSaved: 
      message = @"Mail: saved"; 
      break; 
     case MFMailComposeResultSent: 
      message = @"Mail: sent"; 
//------- call your test method here 
      break; 
     case MFMailComposeResultFailed: 
      message = @"Mail: failed"; 
      break; 
     default: 
      message = @"Mail: not sent"; 
      break; 
    } 
    [self dismissModalViewControllerAnimated:YES]; 
    } 
+0

如何調用這個方法 –

+0

這是一個委託方法,所以它會自動調用。 –

+0

這將無法在模擬器上運行,所以請嘗試在設備上使用。 –

相關問題