iPhone UINavigation 控制器问题?

发布于 2024-08-28 05:37:39 字数 957 浏览 7 评论 0原文

我有3个不同的xib。我可以使用以下代码在视图 1 和视图 2 之间来回切换...

此代码将显示第二个视图...

-(IBAction)startButtonClicked:(id)sender{

    self.gamePlayViewController = [[GamePlayViewController alloc] initWithNibName:@"GamePlayViewController" bundle:nil];
    [self.navigationController pushViewController:gamePlayViewController animated:YES];
    [GamePlayViewController release];


}

此代码在第二个视图中执行,并将我带回到第一个视图...

-(IBAction)backButtonClicked{

[self.navigationController popViewControllerAnimated:YES];

}

现在,当我尝试执行此代码(在第二个视图中)以进入第三个视图时...我收到 SIGABRT 并且应用程序崩溃...为什么它适用于第一个视图第二个视图,但不是为第二个视图带来第三个视图?

-(IBAction)nextView{

self.thirdViewController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
        [self.navigationController pushViewController:thirdViewController animated:YES];
        [thirdViewController release];

}

I have 3 different xib's. I am able to go back and forth between view 1 and view 2 with the following code...

This Code brings up the second view...

-(IBAction)startButtonClicked:(id)sender{

    self.gamePlayViewController = [[GamePlayViewController alloc] initWithNibName:@"GamePlayViewController" bundle:nil];
    [self.navigationController pushViewController:gamePlayViewController animated:YES];
    [GamePlayViewController release];


}

This Code is executed in the second view and brings me back to the first view...

-(IBAction)backButtonClicked{

[self.navigationController popViewControllerAnimated:YES];

}

Now when I try to execute this code (in the second view) to get to the third view...I get SIGABRT and the app crashes...why does it work for the first view bringing up the second view, but not for the second view bringing up the 3rd view?

-(IBAction)nextView{

self.thirdViewController = [[ThirdViewController alloc] initWithNibName:@"ThirdViewController" bundle:nil];
        [self.navigationController pushViewController:thirdViewController animated:YES];
        [thirdViewController release];

}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

只等公子 2024-09-04 05:37:39

ThirdViewController.xib 中可能有一些您忘记配置或配置错误的对象或出口。比较和对比 ThirdViewController.xib 和 GamePlayViewController.xib,密切注意如何配置 ThirdViewController.xib 的类名和出口。特别是:

  1. 确保您的文件所有者已正确设置为 ThirdViewController。
  2. 确保文件所有者的视图出口正确连接到其视图。

There's probably some object or outlet in ThirdViewController.xib that you've forgotten to configure or misconfigured. Compare and contrast ThirdViewController.xib and GamePlayViewController.xib, paying close attention to how you've configured ThirdViewController.xib's class names and outlets. In particular:

  1. Make sure your File's Owner is properly set to ThirdViewController.
  2. Make sure the view outlet of the File's Owner is properly connected to its view.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文