<bdo id='USQfi'></bdo><ul id='USQfi'></ul>
  • <small id='USQfi'></small><noframes id='USQfi'>

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

        <legend id='USQfi'><style id='USQfi'><dir id='USQfi'><q id='USQfi'></q></dir></style></legend>
      1. 使用导航控制器在 Storyboard 中呈现视图控制器 - Swift

        时间:2023-06-10
            <tbody id='V5BD3'></tbody>
        • <small id='V5BD3'></small><noframes id='V5BD3'>

            <tfoot id='V5BD3'></tfoot>

              <legend id='V5BD3'><style id='V5BD3'><dir id='V5BD3'><q id='V5BD3'></q></dir></style></legend>

                  <bdo id='V5BD3'></bdo><ul id='V5BD3'></ul>
                  <i id='V5BD3'><tr id='V5BD3'><dt id='V5BD3'><q id='V5BD3'><span id='V5BD3'><b id='V5BD3'><form id='V5BD3'><ins id='V5BD3'></ins><ul id='V5BD3'></ul><sub id='V5BD3'></sub></form><legend id='V5BD3'></legend><bdo id='V5BD3'><pre id='V5BD3'><center id='V5BD3'></center></pre></bdo></b><th id='V5BD3'></th></span></q></dt></tr></i><div id='V5BD3'><tfoot id='V5BD3'></tfoot><dl id='V5BD3'><fieldset id='V5BD3'></fieldset></dl></div>
                  本文介绍了使用导航控制器在 Storyboard 中呈现视图控制器 - Swift的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我目前在下面的新故事板中展示了一个 viewController:

                  I am currently showing a viewController in my new storyboard below:

                  var storyboard : UIStoryboard = UIStoryboard(name: AccountStoryboard, bundle: nil)
                  var vc : WelcomeViewController = storyboard.instantiateViewControllerWithIdentifier("WelcomeID") as WelcomeViewController
                  vc.teststring = "hello"        
                  self.presentViewController(vc, animated: true, completion: nil)
                  

                  但是,这会呈现没有嵌入式导航控制器的视图控制器.我尝试将WelcomeID"更改为情节提要中的导航控制器 - 但没有成功.

                  However, this presents the viewcontroller without its embedded navigation controller. I tried changing "WelcomeID" to the navigation controller within the storyboard - however to no success.

                  我在 Objective-C 中得到了这个工作,但是不知道如何转换成 swift:

                  I got this working in Objective -C, however don't know how to transform into swift:

                  UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"SetupStoryboard" bundle:nil];
                  UINavigationController *navigationController1 = [storyboard instantiateInitialViewController];
                  navigationController1.modalPresentationStyle = UIModalPresentationFormSheet;
                  navigationController1.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
                  
                  WelcomeViewController *vc = (WelcomeViewController *)navigationController1.viewControllers[0];
                  vc.teststring = @"Hello";
                  
                  [self presentViewController:navigationController1 animated:YES completion:nil];
                  

                  你如何快速做到这一点?

                  How can you do this in swift?

                  推荐答案

                  你绝对是在正确的轨道上.不幸的是,当您通过情节提要 ID 引用视图控制器时,它将忽略它嵌入任何内容的事实.当您选择嵌入的东西时,segues 也是如此,目标视图控制器将是嵌入控制器,而不是您通常感兴趣的控制器.无论如何,您应该能够以类似的方式解决问题Objective-C,所以这只是一个语法移植练习.

                  You're definitely on the right track. Unfortunately when you reference a view controller by its storyboard ID it will ignore the fact it is embedded within anything. Same goes for segues when you segue to something embedded, the destination view controller will be the embedding controller, not the controller you're usually interested in. Anyhow, you should be able to fix the problem in a similar way you've done in Objective-C, so this is just an exercise in syntax porting.

                  现在用字符串定义故事板名称

                  let storyboard : UIStoryboard = UIStoryboard(name: "AccountStoryboard", bundle: nil)
                  let vc : WelcomeViewController = storyboard.instantiateViewControllerWithIdentifier("WelcomeID") as WelcomeViewController
                  vc.teststring = "hello"        
                  
                  let navigationController = UINavigationController(rootViewController: vc)
                  
                  self.presentViewController(navigationController, animated: true, completion: nil)
                  

                  或者你可以给你的嵌入视图控制器一个 ID 并实例化它.

                  OR you can give your embedding view controller an ID and instantiate that instead.

                  这篇关于使用导航控制器在 Storyboard 中呈现视图控制器 - Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:自定义 UINavigationController UIToolbar 背景图片 下一篇:将工具栏添加到 UITableViewController

                  相关文章

                • <tfoot id='pqLHO'></tfoot>
                    <bdo id='pqLHO'></bdo><ul id='pqLHO'></ul>

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

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

                      <legend id='pqLHO'><style id='pqLHO'><dir id='pqLHO'><q id='pqLHO'></q></dir></style></legend>