• <tfoot id='Iha5H'></tfoot>
  • <small id='Iha5H'></small><noframes id='Iha5H'>

      <legend id='Iha5H'><style id='Iha5H'><dir id='Iha5H'><q id='Iha5H'></q></dir></style></legend>
      <i id='Iha5H'><tr id='Iha5H'><dt id='Iha5H'><q id='Iha5H'><span id='Iha5H'><b id='Iha5H'><form id='Iha5H'><ins id='Iha5H'></ins><ul id='Iha5H'></ul><sub id='Iha5H'></sub></form><legend id='Iha5H'></legend><bdo id='Iha5H'><pre id='Iha5H'><center id='Iha5H'></center></pre></bdo></b><th id='Iha5H'></th></span></q></dt></tr></i><div id='Iha5H'><tfoot id='Iha5H'></tfoot><dl id='Iha5H'><fieldset id='Iha5H'></fieldset></dl></div>
        <bdo id='Iha5H'></bdo><ul id='Iha5H'></ul>
      1. 无法为子视图 pushViewController

        Unable to pushViewController for subview(无法为子视图 pushViewController)
        <legend id='4MIky'><style id='4MIky'><dir id='4MIky'><q id='4MIky'></q></dir></style></legend>
          <bdo id='4MIky'></bdo><ul id='4MIky'></ul>
        • <small id='4MIky'></small><noframes id='4MIky'>

                  <tbody id='4MIky'></tbody>

                  <tfoot id='4MIky'></tfoot>

                  <i id='4MIky'><tr id='4MIky'><dt id='4MIky'><q id='4MIky'><span id='4MIky'><b id='4MIky'><form id='4MIky'><ins id='4MIky'></ins><ul id='4MIky'></ul><sub id='4MIky'></sub></form><legend id='4MIky'></legend><bdo id='4MIky'><pre id='4MIky'><center id='4MIky'></center></pre></bdo></b><th id='4MIky'></th></span></q></dt></tr></i><div id='4MIky'><tfoot id='4MIky'></tfoot><dl id='4MIky'><fieldset id='4MIky'></fieldset></dl></div>
                  本文介绍了无法为子视图 pushViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个 UINavigationController,我有单独的 UIView,我在使用 UISegmentControl 之间切换.在切换视图时,我将视图作为子视图添加到导航控制器的视图中:

                  I have a UINavigationController and I have seperate UIViews that I switch between using a UISegmentControl. On switching the views, I add the view as a subview to my navigation controller's view:

                  [self.view addSubview:segmentTab1.view];
                  

                  [self.view addSubview:segmentTab2.view];
                  

                  然后,在 subViews 中,每个都有一个 UITableView,但我的问题是,我无法在 didSelectRowAtIndexPath 方法中将新的 viewController 推送到视图中.

                  Then, in the subViews, each has a UITableView, but my issue is, that I am unable to push a new viewController into view in the didSelectRowAtIndexPath method.

                  该方法被正确调用,通过设置断点,我可以看到推送视图的方法也被调用,但没有任何反应.这是我推送它的代码:

                  The method is called correctly and by setting breakpoints, I can see the method for pushing the view gets called as well, but nothing happens. This is my code for pushing it:

                  [self.navigationController pushViewController:detailsViewController animated:YES];

                  我也试过了

                  [super.navigationController pushViewController:detailsViewController animated:YES];

                  我做错了什么 - 或者只是不可能用子视图来做?

                  What am I doing wrong - or is is just not possible to do it with a subview?

                  推荐答案

                  调用-pushViewController时,self是哪个视图控制器?如果您在其中一个选项卡子视图中调用它,则 self 可能没有从您添加到的顶级视图中对导航控制器的引用.您可以通过从顶级视图中获取导航控制器的内存地址并将其与子视图中的内容进行比较来验证这一点.显然,如果它是 nil 或不匹配,那是你的问题.

                  When you call -pushViewController, which view controller is self? If you are calling that from within one of your tab subviews, self likely doesn't have a reference to the navigation controller from the top level view that you added it to. You can verify this by getting the memory address of the navigation controller from within the top level view and comparing it to what you have in the subview. Obviously if it's nil or doesn't match, then that's your problem.

                  只有使用 -pushViewController 将导航控制器添加到导航堆栈本身时,您才能免费"获得导航控制器,而您的子视图尚未以这种方式添加.

                  You only get a navigation controller "for free" when it's been added to the navigation stack itself with -pushViewController which your subviews haven't been added that way.

                  这篇关于无法为子视图 pushViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                  ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                  Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
                  How to get the previous viewcontroller that pushed my current view(如何获取推送我当前视图的上一个视图控制器)
                  The correct way to set a light status bar text color in iOS 7 based on different ViewControllers(iOS 7中基于不同ViewControllers设置灯光状态栏文字颜色的正确方法)
                  Show UITabBar when UIViewController pushed(推送 UIViewController 时显示 UITabBar)
                  <legend id='YRI8V'><style id='YRI8V'><dir id='YRI8V'><q id='YRI8V'></q></dir></style></legend>
                      • <bdo id='YRI8V'></bdo><ul id='YRI8V'></ul>

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

                          <tfoot id='YRI8V'></tfoot>

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