在UITabBarController和UINavigationController中以编程方式显示视图

时间:2019-01-28 16:57:33

标签: ios swift uinavigationcontroller uitabbarcontroller viewcontroller

我们正在开发一个具有RootVC的iOS应用,该应用中以编程方式放置了4个TAB,每个选项卡都有一个单独的ViewController。负责搜索的选项卡之一。当用户在特定的ViewController上点击搜索按钮时,我们想在另一个ViewController中显示搜索结果,该TabBar在底部,{{1} }顶部的“返回”按钮。 我该如何实现?我尝试使用NavigationController进行推送,但没有一个起作用。

RootVC.swift:

self.navigationController?.present

1 个答案:

答案 0 :(得分:1)

尝试一下

var vc = storyboard?.instantiateViewController(withIdentifier: "identifierForStoryboard

navigationController?.pushViewController(vc, animated: true)

然后观察是否存在诸如视图不在层次结构之类的错误