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

    • <bdo id='tSf6N'></bdo><ul id='tSf6N'></ul>

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

    <legend id='tSf6N'><style id='tSf6N'><dir id='tSf6N'><q id='tSf6N'></q></dir></style></legend>
    1. <tfoot id='tSf6N'></tfoot>
    2. 将 UIBarButtonItem 添加到 UINav..Controller

      时间:2023-06-11

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

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

          <tfoot id='mY01N'></tfoot>

              <tbody id='mY01N'></tbody>
              <bdo id='mY01N'></bdo><ul id='mY01N'></ul>

              1. <legend id='mY01N'><style id='mY01N'><dir id='mY01N'><q id='mY01N'></q></dir></style></legend>
                本文介绍了将 UIBarButtonItem 添加到 UINav..Controller的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我不确定我在这里缺少什么.我有一个自定义 UINavigationController 并且我正在尝试将持久性 UIBarButtonItem 添加到栏.

                <上一页>-(void)viewDidLoad{self.navigationBar.barStyle = UIBarStyleBlack;UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithTitle:@"Nope..."样式:UIBarButtonItemStyleBordered目标:自己动作:@selector(goBack:)];self.navigationItem.leftBarButtonItem =bbi;[bbi 发布];}-(void)goBack:(id)sender{NSLog(@"现在回去");}

                我在这里错过了什么?- 顺便说一句,我不想/不会使用 IB.

                更新:目前这是我能得到的最接近的:

                <上一页>-(void)viewDidLoad{self.navigationBar.barStyle = UIBarStyleBlack;UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, 320, 44)];navBar.barStyle = UIBarStyleBlack;UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:@"正在播放..."];[navBar pushNavigationItem:navItem 动画:NO];UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(goBack:)];navItem.rightBarButtonItem = 编辑按钮;[self.view addSubview:navBar];;[导航项发布];[导航栏发布];[超级视图DidLoad];}

                很糟糕,我必须将整个导航栏添加到已经有导航栏的 UINavigationController....如果我尝试使用现有的,我会收到此错误:

                <上一页>'NSInternalInconsistencyException',原因:'无法调用 pushNavigationItem:动画:直接在控制器管理的 UINavigationBar 上.'

                ....真的吗???

                解决方案

                navigationItem 不能设置在 UINavigationController 实例上,而是设置在 的视图控制器上视图显示在导航控制器内部".

                如果您的控制器本身被推入另一个导航控制器,则在导航控制器上设置 self.navigationItem 将起作用.

                i am not sure what i am missing here. I Have a custom UINavigationController and i am trying to add a persistant UIBarButtonItem to the bar.

                -(void)viewDidLoad
                {
                    self.navigationBar.barStyle = UIBarStyleBlack;
                    UIBarButtonItem *bbi = [[UIBarButtonItem alloc] initWithTitle:@"Nope..."
                               style:UIBarButtonItemStyleBordered
                                 target:self
                                 action:@selector(goBack:)]; 
                    self.navigationItem.leftBarButtonItem =bbi;
                    [bbi release]; 
                }
                -(void)goBack:(id)sender
                {
                    NSLog(@"go back now");
                }
                

                what am i missing here? - BTW, i do not want to/ will not use IB.

                UPDATE: Currently this is the closest i can get:

                -(void)viewDidLoad
                {
                    self.navigationBar.barStyle = UIBarStyleBlack;
                    UINavigationBar *navBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 20, 320, 44)];
                    navBar.barStyle = UIBarStyleBlack;
                    UINavigationItem *navItem = [[UINavigationItem alloc] initWithTitle:@"Currently Playing..."];
                    [navBar pushNavigationItem:navItem animated:NO];
                    UIBarButtonItem *editButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStyleBordered target:self action:@selector(goBack:)];
                    navItem.rightBarButtonItem = editButton;
                
                    [self.view addSubview:navBar];
                
                    [editButton release];
                    [navItem release];
                    [navBar release]; 
                    [super viewDidLoad];
                }
                

                It's terrible i have to add an entire navbar to a UINavigationController that already has a navbar....if i try to use the existing, i get this error:

                'NSInternalInconsistencyException', reason: 'Cannot call pushNavigationItem:animated: directly on a UINavigationBar managed by a controller.'
                

                ....really???

                解决方案

                navigationItem must not be set on the UINavigationController instance but on the view controller of the view which is displayed "inside" the navigation controller.

                Setting self.navigationItem on your navigation controller would work if your controller was itself pushed into another navigation controller.

                这篇关于将 UIBarButtonItem 添加到 UINav..Controller的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何从 navigationController(viewControllers/stack) 弹回指定 viewCon 下一篇:如何更改 UINavigationBar 标题的字体和文字颜色

                相关文章

                    <tfoot id='hxPpm'></tfoot>
                  1. <small id='hxPpm'></small><noframes id='hxPpm'>

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