ios - View over view 打破层次结构

标签 ios swift uiview tableview uisegmentedcontrol

我正在使用 MZFormSheetPresentationController在 ViewController1 上显示为“弹出”ViewController2(按照建议嵌入到导航 Controller 中)。

我的 ViewController1 有一个搜索栏、一个 UISegmentedControl 和一个表格 View :

Image1

当用户单击搜索栏书签按钮时,会显示弹出窗口。

Image2

我想在用户单击“完成”按钮时关闭弹出窗口,并且使用 self.dismissViewControllerAnimated(true,completion: nil) 方法效果很好,但我正在寻找更多。我想再次呈现 ViewController1,以便 tableView 重新加载数据。 我尝试过:

self.dismissViewControllerAnimated(true, completion: nil)
        print("Dismissed")

        //goToTickets
        let next = self.storyboard?.instantiateViewControllerWithIdentifier("myTabBar") as! UITabBarController
        self.presentViewController(next, animated: true, completion: nil)

但是我得到这个错误:

Warning: Attempt to present on whose view is not in the window hierarchy!

弹出窗口消失了,但我无法呈现 ViewController。

我该怎么办?

提前致谢。

编辑

这是我的 ViewController2,标识符为“navigationFilter”

Image4

和我的标签栏:

Image5

最佳答案

当您正在尝试呈现下一个 ViewController 时,您必须等待完成处理程序,然后呈现下一个 View Controller ,如下所示:

self.dismissViewControllerAnimated(true, completion: {
    let next = self.storyboard?.instantiateViewControllerWithIdentifier("myTabBar") as! UITabBarController
    self.presentViewController(next, animated: true, completion: nil)
})

关于ios - View over view 打破层次结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37830043/

相关文章:

ios - 在没有 XCode 的情况下更改 IPA 的最低操作系统版本,iOS 8+

ios - Swift 删除结构数组

ios - 无法分配给属性 : 'item' is a 'let' constant (Swift 4)

ios - 设置 self.window.rootViewController 会导致 SIGABRT

ios - drawRect 不调整大小并跑出屏幕 3.5 英寸屏幕

iOS - 如何相对于另一个添加一个 UIButton?

ios - 平滑用户体验的游戏 Assets 加载策略

ios - 删除 CKRecord 真的很困惑

swift - 如何从 YouTube Api 中的类别获取视频列表

ios - swift - 我很笨,我的 subview 不会服从并正确调整自身大小