【问题标题】:Going back from Storyboard ViewController to a previously used .xib ViewController从 Storyboard ViewController 返回到以前使用的 .xib ViewController
【发布时间】:2014-01-24 21:01:05
【问题描述】:

我有一个通过一系列视图控制器运行的应用程序。我们将其绘制成这样:

IntroViewController -> MenuViewController -> Test1StoryBoard
                                          -> Test2ViewController
                                          -> Test3ViewController

其中有一个介绍屏幕,然后是一个菜单屏幕,您可以在其中选择 Test1、Test2 或 Test3。然而,由于这是一个由几个人制作的相当大的应用程序,所以我将测试 1 制作为故事板,而其余的都是 .xibs。在Test1结束时,我想回到MenuViewController,所以我使用了:

mVC = [[MenuViewController alloc] init];
self.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
[self presentViewController:mVC animated:YES completion:nil];

这段代码成功地将用户带回到 MenuViewController。但是,一旦我们回到 MenuViewController,通常会将用户带回 Test1、Test2 或 Test3 的按钮将不起作用。没有错误消息,但是单击它们时什么也没有发生。我知道这个问题有点含糊,如有必要,我很乐意提供更多代码,但有人能说明问题可能是什么吗?

【问题讨论】:

  • 当您从 Test1 转到 MenuVC 时,不要再次创建新的视图控制器。调用dismissViewControllerAnimated:completion: 或调用popViewControllerAnimated: 方法,具体取决于您用来呈现Test1 或Test2 或Test3 的内容。另外,您能否发布您从 MenuViewController 实例化 Test1、test2 和 test3 的方式的代码。
  • @user1190882,您应该重新发布您的评论作为答案。这是正确的答案,然后 OP 应该接受它。对于 OP,使用 alloc/init 创建一个新的 menuViewController 副本。现在你有 2 个,一个是之前设置的,一个是全新的,可能没有正确配置,但现在堆叠在其他视图控制器之上。真是一团糟。
  • 好的@DuncanC。将其发布为答案。 :)

标签: ios objective-c xcode uiviewcontroller uistoryboard


【解决方案1】:

当您从 Test1 转到 MenuVC 时,不要再次创建新的视图控制器。调用dismissViewControllerAnimated:completion: 或调用popViewControllerAnimated: 方法,具体取决于您用来呈现Test1 或Test2 或Test3 的内容,分别是presentViewController:animated:completion:pushViewController:animated

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-01-24
    • 2013-11-04
    • 2012-04-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-01-19
    相关资源
    最近更新 更多