3

After though that after using MFMailComposeViewController the move to MFMessageComposeViewController was straight foward, but there is a catch.

Suppose this code:

MFMessageComposeViewController* mySMS = [[MFMessageComposeViewController alloc] init];
[mySMS setDelegate:self];
[self presentModalViewController:mySMS animated:YES];

It works this way for mails, but in sms you should set different the delegate to an internal structure like this:

[SMS setMessageComposeDelegate:self];

Hope you don not get stuck on this as I did early today.

4

2 に答える 2

4

デリゲートメソッドを実装する必要があります-(void)mailComposeController(MFMailComposeViewController*)controller didFinishWithResult (MFMailComposeResult)result error:(NSError*)error:

そしてその中であなたはそれを自分で却下するべきです:

-(void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
    [self dismissModalViewControllerAnimated:YES]; 
}
于 2011-10-28T20:20:57.007 に答える
0

Apple のドキュメントで MFMailComposeResult を確認できます。

  enum MFMailComposeResult {
    MFMailComposeResultCancelled,
    MFMailComposeResultSaved,
    MFMailComposeResultSent,
    MFMailComposeResultFailed
 };
 typedef enum MFMailComposeResult MFMailComposeResult; 

そして、デリゲートメソッドで自分でコントローラーを閉じる必要があります

 - (void) mailComposeController:(MFMailComposeViewController *)controller          didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
 {
  switch (result){
    case MFMailComposeResultCancelled:
        NSLog(@"Mail cancelled");
        break;
    case MFMailComposeResultSaved:
        NSLog(@"Mail saved");
        break;
    case MFMailComposeResultSent:
        NSLog(@"Mail sent");
        break;
    case MFMailComposeResultFailed:
        NSLog(@"Mail sent failure: %@", [error localizedDescription]);
        break;
    default:
        break;
   }
// Close the Mail Interface
   [self dismissViewControllerAnimated:YES completion:NULL];
}
于 2014-07-03T13:10:24.180 に答える