2012-02-17 18 views
0

電子メールモードで「送信」をクリックした後にビューを変更する方法を考えるのに問題があります。私は、ユーザーが記入したフォームであるメインビューを持っています。その情報が電子メールに入力されます。今私が「送信」を押すと、ユーザーはフォームページに戻るのではなく、新しいページに戻るようにします。電子メールを送信した後にビューを変更する

思考?ありがとう!

答えて

1

ビューコントローラインターフェイスにMFMailComposeViewControllerDelegateを追加します。

初期化するときに、現在のビューコントローラにデリゲートを作る ``あなたがこの方法でメールの状態が通知されます

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
    picker.mailComposeDelegate = self; 

はここ

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    // Notifies users about errors associated with the interface 
    switch (result) 
    { 
     case MFMailComposeResultCancelled: 
//   message.text = @"Result: canceled"; 
      break; 
     case MFMailComposeResultSaved: 
         break; 

     case MFMailComposeResultSent: 

      break; 

     case MFMailComposeResultFailed: 
     { 
      UIAlertView *FailedAlert= [[UIAlertView alloc]initWithTitle:@"Mail could not be sent" message:nil delegate:nil cancelButtonTitle:@"Okay" otherButtonTitles:nil, nil]; 
      [FailedAlert show]; 
      [FailedAlert release]; 
      break; 
     } 
     default: 
      NSLog(@"Hit default case in the switch"); 
      break; 
    } 
    [self dismissModalViewControllerAnimated:YES]; 
} 

あなたがする必要がありますあなたの選択と結果に基づいて新しいビューを読み込むことができます。

関連する問題