xcode Swift - 如何从 ViewController 转到 TabBarController

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30419087/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 07:11:22  来源:igfitidea点击:

Swift - How do I segue from ViewController to TabBarController

xcodeswiftuistoryboardsegue

提问by davidgilman

How do I add a ViewControllerbefore a TabBarControllerin Swift? I am using Parse to make a custom login in the ViewControllerwhich would lead to the TabBarController... Help would be appreciated!

如何在 Swift 中在aViewController之前添加 a TabBarController?我正在使用 Parse 在其中进行自定义登录,ViewController这将导致TabBarController...帮助将不胜感激!

采纳答案by Chameleon

1.Control-drag from yellow symbol (ViewController) to the TabBarController

1.Control-drag 从黄色符号 (ViewController) 到TabBarController

enter image description here

在此处输入图片说明



This will create a segue in your ViewControllermenu

这将在您的ViewController菜单中创建一个 segue

enter image description here

在此处输入图片说明



2.Click this new segue "Show segue to Tab..." and in identity inspector set an identifier name.

2.点击这个新的segue“Show segue to Tab...”并在身份检查器中设置一个标识符名称。

enter image description here

在此处输入图片说明



3.Now when you want to make the segue happen, use call...

3.现在,当你想让 segue 发生时,使用 call...

performSegueWithIdentifier("WhatEveryYouNamedSegue", self)

回答by JustinvR

This is the way I transfer from the login view controller to my home view controller tab bar.

这是我从登录视图控制器转移到我的主视图控制器选项卡栏的方式。

let homeViewController = self.storyboard?.instantiateViewController(withIdentifier: "HomeVCTabBar") as? UITabBarController

            self.view.window?.rootViewController = homeViewController
            self.view.window?.makeKeyAndVisible()

The most common mistake people make is that they use Instead of UITabBarController the name of the VC they go to.

人们最常犯的错误是他们使用他们去的 VC 的名称而不是 UITabBarController 。

Make sure you use UITabBarController to entry the first view from your TabBarController.

确保使用 UITabBarController 从 TabBarController 进入第一个视图。