【发布时间】:2015-11-16 00:16:54
【问题描述】:
好的..这就是问题所在。当我点击主菜单中的[播放]按钮时,它应该根据这段代码进入相应的ViewController:
@IBAction func playButton(sender: AnyObject) {
if rightCounter <= 4 {
if let Level1 = self.storyboard!.instantiateViewControllerWithIdentifier("Level1") as? Level1 {
self.presentViewController(Level1, animated: true, completion: nil)
}
}
if rightCounter >= 5 && rightCounter <= 9 {
if let Level2 = self.storyboard!.instantiateViewControllerWithIdentifier("Level2") as? Level2 {
self.presentViewController(Level2, animated: true, completion: nil)
}
}
}
代码运行完美!没有错误!但是当 rightCounter 为 9 时,它仍然将我带到第一个 ViewController。实际上它应该带我到第二个 ViewController。这就是我们必须修复的地方。顺便说一句,提前谢谢。
在那段时间里,我也收到了这个错误。
Warning: Attempt to present <GuessMeFinal.Level2: 0x79eb7500> on <GuessMeFinal.ViewController: 0x7ac62180> whose view is not in the window hierarchy!
我已将 mainViewController 连接到 Level1 和 Level2 ViewControllers。那么,我应该使用其他代码来解决我的问题,还是请在这里帮助我!
【问题讨论】:
-
现在,真正的问题是:代码中没有错误,但我的应用程序没有按照我编写的代码运行。例如:如果我的右侧计数器是 5,我知道它是 5,它应该带我到 Level2 VC,但它仍然带我到 Level1 VC。请帮忙!
-
可能是因为 MainViewController 无法访问我存储在一个视图控制器中的 rightCounter 值?
-
我确实在第二个 if 命令的开头放置了一个断点。现在有显示 Thread1: Breakpoint 的绿色突出显示。应用卡住了,上面写着
GuessMeFinal[1893:1599218] Could not load the "" image referenced from a nib in the bundle with identifier "com.SKApps.GuessMeFinal"这是什么意思? -
为了清楚起见,我已将 rightCounter 值存储在 Level1 VC 和 Level2 VC 中,但未存储在 MainViewController 中。这会是个问题吗?
-
@matt 帮帮我。!请..!
标签: ios iphone xcode swift uiviewcontroller