在我的应用程序中,用户可以提交类似于 Instagram 的新帖子。但是,如果他们决定不发帖,可以按 UITabBarButton
上的“取消”按钮,它将加载最新的帖子。
我已经四处寻找解决方案,但它们主要是UIViewController
。
showViewController Not Working
但是,我需要的是强制打开 UITableViewController
。我的代码如下,我知道它不起作用,因为它不符合预期的 UIViewController
。
@IBAction func cancelBtn(sender: UIBarButtonItem) {
self.navigationController?.pushViewController(LatestPostViewController as UITableViewController, animated: true)
}
编辑:添加了屏幕截图以更好地进行说明。因此,“取消”按钮嵌入在“相机”选项卡内的导航 Controller 中。当用户按 UINavigationBar
Latest Post
选项卡
抱歉,我没有足够的声誉来直接显示图像。
最佳答案
检查并确保您的取消按钮操作设置正确。在您想要转移到适当选项卡的操作中:
@IBAction func cancelBtn(sender: UIBarButtonItem) {
self.tabBarController?.selectedIndex = 0
}
关于ios - 如何以编程方式显示 UITableViewController,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34880718/