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

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

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

      UINavigationController 中的自定义后退按钮

      Custom back button in UINavigationController(UINavigationController 中的自定义后退按钮)
      • <tfoot id='JgBtP'></tfoot>

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

          <tbody id='JgBtP'></tbody>

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

                本文介绍了UINavigationController 中的自定义后退按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                对于我正在开发的应用程序,我需要在导航栏中显示自定义后退按钮.我将按钮资产作为 PNG 图像,我正在编写以下代码:

                For an application I'm developing, I need to display a custom back button in a navigation bar. I have the button asset as a PNG image, and I'm writing this code:

                - (void)viewWillAppear:(BOOL)animated {
                    [super viewWillAppear:animated];
                    UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom];
                    backButton.frame = CGRectMake(0, 0, 79, 29.0);
                    [backButton setImage:[UIImage imageNamed:@"button_back.png"] forState:UIControlStateNormal];
                    self.navigationItem.backBarButtonItem = [[[UIBarButtonItem alloc] initWithCustomView:backButton] autorelease];
                

                }

                当我按下这个视图控制器时,自定义按钮没有显示出来,而是我得到了标准的后退按钮,里面有这个视图控制器的标题.

                When I push this view controller, the custom button does not show up, and instead I get the standard back button with the title of this view controller inside.

                我已经尝试过的事情:

                1. 通过将按钮 backButton 添加到视图层次结构中,双重检查按钮是否正确创建.它可以正常显示.
                2. 以同样的方法,更改 navigationItemtitle 属性,并确认它更改(如预期)我的后退按钮的内容.
                1. Doubled check that the button backButton is created properly, by adding it to the view hierarchy. It displays properly.
                2. In the same method, changed the title property of the navigationItem and confirmed that it changes (as expected) the content of my back button.

                谁能发现我做错了什么?有没有人通过 UINavigationController 成功使用自定义图像作为后退按钮?

                Can anyone spot what I'm doing wrong? Did anyone succeed in using a custom image as the back button on with a UINavigationController?

                推荐答案

                backBarButtonItem 属性按预期工作,但它始终会根据导航栏色调添加其标准按钮形状和颜色.

                The backBarButtonItem property works as intended, but it will always add its standard button shape and color based on the navigation bar tint color.

                您可以自定义文本,但不能替换图像.

                You can customize the text, but not replace the image.

                正如 Andrew Pouliot 所建议的,一种解决方法是改用 leftBarButtonItem,但我还是坚持使用标准按钮.

                One workaround, as Andrew Pouliot suggested, is to use leftBarButtonItem instead, but I stuck to the standard button instead.

                这篇关于UINavigationController 中的自定义后退按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                相关文档推荐

                UINavigationController inside a UITabBarController inside a UISplitViewController presented modally on iPhone(UISplitViewController 内的 UITabBarController 内的 UINavigationController 以模态方式呈现在 iPhone 上) - IT屋-程序员软件开发技术分
                ViewController in UINavigationController orientation change(UINavigationController 中的 ViewController 方向更改)
                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)
                presentViewController not supporting orientation in iOS 6(presentViewController 在 iOS 6 中不支持方向)

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

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

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

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