• <tfoot id='BxkB0'></tfoot>

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

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

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

      1. 使用 segues 在 NavigationController 中嵌入 UIViewController

        时间:2023-05-17
        • <bdo id='MV2zc'></bdo><ul id='MV2zc'></ul>
        • <tfoot id='MV2zc'></tfoot>
            <tbody id='MV2zc'></tbody>

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

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

                <legend id='MV2zc'><style id='MV2zc'><dir id='MV2zc'><q id='MV2zc'></q></dir></style></legend>
                • 本文介绍了使用 segues 在 NavigationController 中嵌入 UIViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我有一个 viewController,通常(最常)通过使用 push segue 访问.这个 viewController 需要嵌入到 UINavigationController 中.所以通常,这没有问题.push segue 管理 viewController 的推送,因此 viewController 拥有它的 UINavigationController.

                  I have a viewController that is usually (most often) accessed by using a push segue. This viewController needs to be embedded in a UINavigationController. So typically, this is no problem. The push segue manages pushing the viewController, and therefore the viewController has it's UINavigationController.

                  我的问题是,在某些情况下,我想使用模态 segue 呈现相同的视图控制器.当我这样做时,viewController 没有嵌入到导航控制器中.有没有办法使用 segues 做到这一点?

                  My issue is that in a few cases, I'd like to present this same exact viewController using a modal segue. When I do this, the viewController is not embedded in a navigationController. Is there a way to do this using segues?

                  我知道这可以通过创建 UINavigationController,将 rootView 设置为 viewController,然后以模态方式呈现,从而完全在代码中完成.这可以使用这样的代码来完成:

                  I know this can be done purely in code without segues by creating a UINavigationController, setting the rootView as the viewController and then presenting that modally. That can be done using code like this :

                  MyViewController *viewController = [[MyViewController alloc] init];
                  UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:viewController];
                  [self presentModalViewController:navController animated:YES];
                  

                  但是除了使用 Segues 之外,我该如何做同样的事情呢?

                  But how do I do this same thing but using Segues?

                  为了更清楚起见,这里有一些代码来补充我如何在 prepareForSegue 方法中使用接受的答案.

                  For further clarity, here is some code to supplement how I used the accepted answer in the prepareForSegue method.

                  使用模态转场时

                  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
                  {
                      if ([[segue destinationViewController] isEqualToString:@"Modal to MyVC"])
                      {
                          UINavigationController *nav = [segue destinationViewController];
                          MyViewController *vc = [nav topViewController];
                          //setup vc
                      }
                  }
                  

                  使用 Push Segue 时

                  - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
                  {
                      if ([[segue destinationViewController] isEqualToString:@"Push to MyVC"])
                      {
                          MyViewController *vc = [segue destinationViewController];
                          //setup vc
                      }
                  }
                  

                  推荐答案

                  在你的 Storyboard 中,你可以通过选择 View Controller 然后从顶部的菜单中选择来将 ViewController 嵌入到 Navigation Controller 中 Editor->嵌入->导航控制器.从另一个视图控制器,您控制拖动到此导航控制器以设置 modal segue.您还可以控制拖动到原始 View Controller 以在没有 Navigation Controller 的情况下为其设置 segues.

                  In your Storyboard, you can embed a ViewController in a Navigation Controller by selecting the View Controller and then picking from the menu at the top Editor->Embed In->Navigation Controller. From another view controller, you control drag to this Navigation controller to set up the modal segue. You can also control drag to the original View Controller to set up segues to it without the Navigation Controller.

                  这篇关于使用 segues 在 NavigationController 中嵌入 UIViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:为栏按钮项目设置图像和标题? 下一篇:用 NavigationViewController 快速呈现 ViewController

                  相关文章

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

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