[英]Segue VC With Tab App Swift
I am trying to segue between view controllers in my application, but have used a Tabbed application template. 我试图在我的应用程序中的视图控制器之间进行筛选,但是使用了选项卡式应用程序模板。 This is my first time using the tab based application, and I am having trouble calling a segue from the second VC to the first on a button click.
这是我第一次使用基于选项卡的应用程序,单击按钮时,我很难从第二个VC调用到第二个VC。
I have tried both creating a segue in the storyboard like so self.performSegue(withIdentifier: "SegueToCalc", sender: nil)
and programmatically creating and calling the segue, but both of which load just the screen without the tab bar at the bottom. 我尝试过像在
self.performSegue(withIdentifier: "SegueToCalc", sender: nil)
这样的情节self.performSegue(withIdentifier: "SegueToCalc", sender: nil)
并以编程方式创建和调用序列,但这两者self.performSegue(withIdentifier: "SegueToCalc", sender: nil)
加载屏幕而底部没有选项卡栏。 I believe their is a way to call the TabController in order to set which index is selected, but I have tried below and this does not work either: 我相信他们是一种调用TabController来设置选择哪个索引的方法,但是我在下面尝试过,但这也不起作用:
var tabBarController: UITabBarController?
tabBarController?.selectedIndex = 0
You're already on the right track, however, you're creating a new UITabBarController and not accessing the one you already have. 您已经走上了正确的轨道,但是,您正在创建一个新的UITabBarController,而不访问您已经拥有的UITabBarController。 You can access a possible UITabBarController directly from it's viewControllers.
您可以直接从其viewControllers访问可能的UITabBarController。
@IBAction func onButton(_ sender: Any) {
self.tabBarController?.selectedIndex = 0
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.