2012-02-17 46 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]; 
} 

在這裏,你應該能夠根據您的選擇和結果加載新的視圖。