发送电子邮件后更改视图

时间:2012-02-17 18:46:19

标签: objective-c xcode4

在电子邮件模式下点击“发送”后,我无法想办法改变视图。我有一个主视图,这是一个用户填写的表单,该信息然后填充电子邮件。现在,当我点击“发送”时,我不希望用户返回表单页面而是返回新页面。

思考?谢谢!

1 个答案:

答案 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];   
}

在这里,您应该能够根据您的选择和结果加载新视图。