<tfoot id='YRWBt'></tfoot>
  • <legend id='YRWBt'><style id='YRWBt'><dir id='YRWBt'><q id='YRWBt'></q></dir></style></legend>
      <bdo id='YRWBt'></bdo><ul id='YRWBt'></ul>

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

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

        如何向 UINavigationController 添加右键?

        时间:2023-05-17

          <bdo id='78U2p'></bdo><ul id='78U2p'></ul>
                <tfoot id='78U2p'></tfoot>
                  <tbody id='78U2p'></tbody>
                <legend id='78U2p'><style id='78U2p'><dir id='78U2p'><q id='78U2p'></q></dir></style></legend>

                <small id='78U2p'></small><noframes id='78U2p'>

                <i id='78U2p'><tr id='78U2p'><dt id='78U2p'><q id='78U2p'><span id='78U2p'><b id='78U2p'><form id='78U2p'><ins id='78U2p'></ins><ul id='78U2p'></ul><sub id='78U2p'></sub></form><legend id='78U2p'></legend><bdo id='78U2p'><pre id='78U2p'><center id='78U2p'></center></pre></bdo></b><th id='78U2p'></th></span></q></dt></tr></i><div id='78U2p'><tfoot id='78U2p'></tfoot><dl id='78U2p'><fieldset id='78U2p'></fieldset></dl></div>
                  本文介绍了如何向 UINavigationController 添加右键?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  限时送ChatGPT账号..

                  我正在尝试将刷新按钮添加到导航控制器的顶部栏,但没有成功.

                  I am trying to add a refresh button to the top bar of a navigation controller with no success.

                  这是标题:

                  @interface PropertyViewController : UINavigationController {
                  
                  }
                  

                  这是我尝试添加它的方式:

                  Here is how I am trying to add it:

                  - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
                      if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
                          UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Show" style:UIBarButtonItemStylePlain
                                                            target:self action:@selector(refreshPropertyList:)];      
                          self.navigationItem.rightBarButtonItem = anotherButton;
                      }
                      return self;
                  }
                  

                  推荐答案

                  尝试在 viewDidLoad 中进行.一般来说,你应该尽可能推迟任何事情,直到那个时候,当 UIViewController 被初始化时,它可能还需要很长一段时间才能显示出来,提前工作和占用内存是没有意义的.

                  Try doing it in viewDidLoad. Generally you should defer anything you can until that point anyway, when a UIViewController is inited it still might be quite a while before it displays, no point in doing work early and tying up memory.

                  - (void)viewDidLoad {
                    [super viewDidLoad];
                  
                    UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] initWithTitle:@"Show" style:UIBarButtonItemStylePlain target:self action:@selector(refreshPropertyList:)];          
                    self.navigationItem.rightBarButtonItem = anotherButton;
                    // exclude the following in ARC projects...
                    [anotherButton release];
                  }
                  

                  至于为什么它目前不工作,我不能在没有看到更多代码的情况下 100% 肯定地说,但是在 init 和视图加载之间发生了很多事情,你可能正在做一些导致 navigationItem 的事情在两者之间重置.

                  As to why it isn't working currently, I can't say with 100% certainty without seeing more code, but a lot of stuff happens between init and the view loading, and you may be doing something that causes the navigationItem to reset in between.

                  这篇关于如何向 UINavigationController 添加右键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:以编程方式在 UINavigationController 中设置 UINavigationBar 的自定义子类 下一篇:如何在 UINavigationBar 上设置后退按钮的文本?

                  相关文章

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

                    2. <tfoot id='e3Xb3'></tfoot>