警告:尝试呈现< GuessMeFinal>在< GuessMeFinal.ViewController>上其视图不在窗口层次结构中-Swift [英] Warning: Attempt to present <GuessMeFinal> on <GuessMeFinal.ViewController> whose view is not in the window hierarchy -Swift

查看:59
本文介绍了警告:尝试呈现< GuessMeFinal>在< GuessMeFinal.ViewController>上其视图不在窗口层次结构中-Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧..这是问题所在.当我单击主菜单中的[播放]按钮时,它应根据以下代码转到相应的ViewController:

Okay..here's the problem. When I click the [Play] button in the main menu, it should go to the corresponding ViewController according to this code:

@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.那是我们必须修复的地方.顺便说一句,谢谢你.

The code works perfect! No errors! But when the rightCounter is 9, it still takes me to the first ViewController. Actually it should be taking me to the second ViewController. That's where we have to fix. Btw, thanks in advance.

在那段时间里,我也收到了这个错误.. Warning: Attempt to present <GuessMeFinal.Level2: 0x79eb7500> on <GuessMeFinal.ViewController: 0x7ac62180> whose view is not in the window hierarchy!

And during that time, I get this error too.. Warning: Attempt to present <GuessMeFinal.Level2: 0x79eb7500> on <GuessMeFinal.ViewController: 0x7ac62180> whose view is not in the window hierarchy!

我已经将mainViewController连接到Level1和Level2 ViewController.因此,我应该使用其他代码来解决我的问题,还是请在这里为我提供帮助!

I have connected the mainViewController to the Level1 and Level2 ViewControllers. So, should I use another code to solve my problem, or please help me out here!

推荐答案

我以前遇到过此问题.当您尝试提供未嵌入在同一导航/选项卡栏控制器中的视图控制器时,就会发生这种情况.

I have had this problem before. It happens when you try to present a view controller that is not embedded in the same navigation/tab bar controller.

这将失败:

如果您尝试突出显示突出显示的序列,则您的应用将崩溃.我不知道这是否是您要尝试的操作,但是我之前遇到过此错误.您可能还想看看这个非常相似的问题.

If you try to present the highlighted segue your app will crash. I don't know if this is what you are trying to do but I have encountered this error before. You may also want to look at this very similar question.

希望这会有所帮助.

这篇关于警告:尝试呈现&lt; GuessMeFinal&gt;在&lt; GuessMeFinal.ViewController&gt;上其视图不在窗口层次结构中-Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆