iPhoneSDK:从一个视图中启动多个视图?

时间:2009-11-03 22:20:23

标签: iphone

我有一个非常简单的报名表。按下按钮后,我需要显示从该视图启动的另外两个视图。这是错误。我不理解这个错误。我以为我已经宣布了两种不同的类型。评论赞赏。

009-11-03 17:17:29.008 eProcessing-iPhone [34257:207] ***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:'不支持多次推送同一个视图控制器实例( )'

以下是代码:

confirmViewController *anotherViewController = [[confirmViewController alloc] initWithNibName:@"confirmView" bundle:nil];

//set properties
anotherViewController.strConfirmation = [request responseString];
anotherViewController.strCardNumber = txtCardNumber.text;
anotherViewController.strExpires = txtExpires.text;
anotherViewController.strAmount = txtGrandTotal.text;   

[self.navigationController pushViewController:anotherViewController animated:YES];


//reset interface
if([anotherViewController.strApproval compare:@"""Y"] == NSOrderedSame)
{
    txtCardNumber.text = @"";
    txtExpires.text = @"";
    txtGrandTotal.text = @"";
    txtZip.text = @"";
    txtCCV2.text = @"";
    txtEmail.text = @"";
    txtInvoice.text = @"";
}

[anotherViewController release];


//show signature
sigCaptureViewController *yetAnotherViewController = [[sigCaptureViewController alloc] initWithNibName:@"sigCaptureView" bundle:nil];
[self.navigationController pushViewController:anotherViewController animated:YES];
[yetAnotherViewController release];

2 个答案:

答案 0 :(得分:1)

也许你说的是

[self.navigationController pushViewController:anotherViewController animated:YES];
你的意思是

[self.navigationController pushViewController:yetAnotherViewController animated:YES];

错误是说导航视图堆栈上的视图控制器不能两次。

答案 1 :(得分:1)

您正在推动同一个视图控制器两次:

[self.navigationController pushViewController:anotherViewController animated:YES];

错误源于你正在做的事情:

[anotherViewController release];

然后几行你正在做:

[self.navigationController pushViewController:anotherViewController animated:YES];