【问题标题】:View controller transition error查看控制器转换错误
【发布时间】:2015-08-09 02:09:22
【问题描述】:

我在关闭多点连接窗口后收到此错误:

"Warning: Attempt to present < AudioWaves.ViewControllerJoin: 0x176cf2d0> on < AudioWaves.ViewController: 0x17594de0>  whose view is not in the window hierarchy!"

下面是我的代码,

func browserViewControllerDidFinish(
    browserViewController: MCBrowserViewController!)  {
        // Called when the browser view controller is dismissed (ie the Done
        // button was tapped)
        let ViewControllerjoin:ViewControllerJoin = ViewControllerJoin()

        self.presentViewController(ViewControllerjoin, animated: true, completion: nil)
        dismissViewControllerAnimated(true, completion: nil)

}

如果我在新的视图控制器出现之前关闭浏览器,浏览器就会关闭,但是应用程序只会进入一个没有错误的空白黑屏。

【问题讨论】:

    标签: ios swift segue multipeer-connectivity


    【解决方案1】:

    像这样链接你的两个调用:

    dismissViewControllerAnimated(true, completion: {
        self.presentViewController(ViewControllerjoin, animated: true, completion: nil)
    })
    

    这种方式首先链接dismissViewControllerAnimated,然后链接presentViewController,这样可以防止你的层次结构出现奇怪的行为

    这有助于提问者验证他的 ViewController 确实是黑屏: 尝试将 ViewControllerJoin 的背景颜色更改为蓝色,然后再试一次,一旦我看到默认的 backgroundColor 导致ViewController 中的黑屏(这似乎有助于

    【讨论】:

    • 这样做会使第一个视图根本不会消失,也无法离开
    • 这与另一个视图被关闭然后导致黑屏的方法完全相同
    • 请详细说明您的视图控制器及其出现的顺序
    • 我认为您的主 ViewController 可能有问题,从您呈现 MCBrowserViewController 的位置和您想要呈现 ViewControllerJoin 的位置,如果没有,然后尝试更改背景颜色ViewControllerJoin 以蓝色为例,然后再试一次,一旦我看到默认的 backgroundColor 导致 ViewController 出现黑屏
    • 是的,我在 viewdidload 中将默认背景颜色设置为红色,而不是黑屏,而是红屏,但是当我向原始视图控制器添加一个按钮时ViewControllerJoin 背景颜色是红色的,但它显示了视图控制器的其余部分,我只是不知所措。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-05
    相关资源
    最近更新 更多