<i id='xAeIc'><tr id='xAeIc'><dt id='xAeIc'><q id='xAeIc'><span id='xAeIc'><b id='xAeIc'><form id='xAeIc'><ins id='xAeIc'></ins><ul id='xAeIc'></ul><sub id='xAeIc'></sub></form><legend id='xAeIc'></legend><bdo id='xAeIc'><pre id='xAeIc'><center id='xAeIc'></center></pre></bdo></b><th id='xAeIc'></th></span></q></dt></tr></i><div id='xAeIc'><tfoot id='xAeIc'></tfoot><dl id='xAeIc'><fieldset id='xAeIc'></fieldset></dl></div>
<legend id='xAeIc'><style id='xAeIc'><dir id='xAeIc'><q id='xAeIc'></q></dir></style></legend>
    <bdo id='xAeIc'></bdo><ul id='xAeIc'></ul>

      1. <small id='xAeIc'></small><noframes id='xAeIc'>

        <tfoot id='xAeIc'></tfoot>

        如何在 Swift 编程中获得基于导航的模板功能

        时间:2023-05-17

            <legend id='vamLi'><style id='vamLi'><dir id='vamLi'><q id='vamLi'></q></dir></style></legend>
            <i id='vamLi'><tr id='vamLi'><dt id='vamLi'><q id='vamLi'><span id='vamLi'><b id='vamLi'><form id='vamLi'><ins id='vamLi'></ins><ul id='vamLi'></ul><sub id='vamLi'></sub></form><legend id='vamLi'></legend><bdo id='vamLi'><pre id='vamLi'><center id='vamLi'></center></pre></bdo></b><th id='vamLi'></th></span></q></dt></tr></i><div id='vamLi'><tfoot id='vamLi'></tfoot><dl id='vamLi'><fieldset id='vamLi'></fieldset></dl></div>

              <small id='vamLi'></small><noframes id='vamLi'>

              • <bdo id='vamLi'></bdo><ul id='vamLi'></ul>
                <tfoot id='vamLi'></tfoot>
                  <tbody id='vamLi'></tbody>
                • 本文介绍了如何在 Swift 编程中获得基于导航的模板功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我的项目需要一个导航控制器,并且我的应用程序最初有一个社交登录.验证身份验证后,用户将被推送到另一个视图,在该视图中我会显示一个具有 2 个选项卡的 tabbarcontroller.

                  I need a navigation controller through out my project and my application has a social login initially. Once the authentication is verified user will be pushed to another view, where I display a tabbarcontroller having 2 tabs.

                  我不知道如何在 Swift 编程中做到这一点.我已经将我的视图控制器嵌入到导航控制器中,一旦身份验证成功,我如何将用户推送到标签栏视图?标签栏也应该有导航.

                  I don't know how to do this in Swift programming. I have embed my viewcontroller in Navigation controller, from here once the authentication is successful how do I push user to tabbar view? Tabbar should also have navigation.

                  推荐答案

                  我想将您的想法复制到我通常在以下示例中执行的操作中.

                  I would like to replicate your idea into what I usually do in the following example.

                  这就是我的故事板的样子:

                  This is how my storyboard looks like:

                  如您所见,登录/注册和标签栏未与任何类型的 Segue 连接.

                  As you can see login/signup and Tab bar is not connected with any kind of Segue.

                  此处登录导航控制器是初始控制器的设置.

                  Here Sign in Navigation controller is setup of Initial Controller.

                  为这个导航控制器分配一个故事板 ID(例如LoginNavigation):

                  Assign This Navigation Controller an Storyboard ID(e.g.LoginNavigation):

                  对 Tab Bar Controller 执行相同操作,分配 Storyboard ID(例如 HomeTabBar)

                  Do the same with Tab Bar Controller, assign Storyboard ID(e.g. HomeTabBar)

                  现在,您只需在 Login Nav 和 Tab Bar 之间移动应用程序的 Root View Controller.

                  Now, you just have to shuffle Root View Controller of the app between Login Nav and Tab Bar.

                  因此,如果用户成功登录,则使用以下代码将应用程序的根视图更改为 HomeTabBar:

                  So if user successfully logs in, changes the application's root view to HomeTabBar using following code:

                  let storyboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
                  let home: UITabBarController = storyboard.instantiateViewControllerWithIdentifier("HomeTabBar") as! UITabBarController
                  appDelegate.window?.rootViewController = home
                  

                  当用户登录我们时,再次将根视图更改为 Login Nav:

                  And when user logs our, again change the root view to Login Nav:

                  let mainStoryboard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
                  let entryPoint:UIViewController = mainStoryboard.instantiateViewControllerWithIdentifier("LoginNavigation")
                  appDelegate.window?.rootViewController = entryPoint
                  

                  appDelegate 在我的 constants.swift 文件中定义:

                  The appDelegate is defined in my constants.swift file :

                  let appDelegate  = UIApplication.sharedApplication().delegate as! AppDelegate
                  

                  这篇关于如何在 Swift 编程中获得基于导航的模板功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为什么我在使用 UINavigationController 时不能强制横向? 下一篇:在 UINavigationController 中隐藏导航栏时不向后滑动

                  相关文章

                  1. <small id='wAkku'></small><noframes id='wAkku'>

                    1. <tfoot id='wAkku'></tfoot>

                        <bdo id='wAkku'></bdo><ul id='wAkku'></ul>

                      <i id='wAkku'><tr id='wAkku'><dt id='wAkku'><q id='wAkku'><span id='wAkku'><b id='wAkku'><form id='wAkku'><ins id='wAkku'></ins><ul id='wAkku'></ul><sub id='wAkku'></sub></form><legend id='wAkku'></legend><bdo id='wAkku'><pre id='wAkku'><center id='wAkku'></center></pre></bdo></b><th id='wAkku'></th></span></q></dt></tr></i><div id='wAkku'><tfoot id='wAkku'></tfoot><dl id='wAkku'><fieldset id='wAkku'></fieldset></dl></div>

                    2. <legend id='wAkku'><style id='wAkku'><dir id='wAkku'><q id='wAkku'></q></dir></style></legend>