如何以编程方式显示UITableViewController

时间:2016-01-19 15:31:22

标签: ios swift uitableview

在我的应用程序中,用户可以提交类似于Instagram的新帖子。但是,如果他们决定不发帖,他们可以按UITabBarButton上的“取消”按钮,它会加载最新的帖子。

我一直在寻找解决方案,但它们主要是UIViewController

showViewController Not Working

但是,我需要强行打开UITableViewController。我的代码如下,我知道它不起作用,因为它不符合预期的UIViewController

@IBAction func cancelBtn(sender: UIBarButtonItem) {
    self.navigationController?.pushViewController(LatestPostViewController as UITableViewController, animated: true)
}

编辑:添加了屏幕截图,以便更好地说明目的。因此,“取消”按钮嵌入在Camera选项卡内的导航控制器中。当用户按下Latest Post

上的“取消”按钮时,我需要打开UINavigationBar标签

道歉,我没有足够的声誉来直接显示图像。

Image

1 个答案:

答案 0 :(得分:0)

检查以确保您的取消按钮操作设置正确。在要转移到相应选项卡的操作中:

@IBAction func cancelBtn(sender: UIBarButtonItem) {
    self.tabBarController?.selectedIndex = 0
}
相关问题