如何在iPhone中更改UINavigationController的后退按钮的宽度? [英] How to change back bar button's width of a UINavigationController in iPhone?

查看:94
本文介绍了如何在iPhone中更改UINavigationController的后退按钮的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个表视图控制器.说 TableViewController1 TableViewController2 .

I have two table view controllers. Say TableViewController1 and TableViewController2.

当有人点击 TableViewController1 的单元格时,我按下 TableViewController2 .

I push TableViewController2 when someone clicks on the TableViewController1's cell.

我将 TableViewController1 的单击单元格的值设置为 TableViewController2 的后栏按钮的标题值.

I set the TableViewController1's clicked cell's value as the TableViewController2's back bar button's title value.

根据 TableViewController1 单元格字符串的长度,后退按钮的长度也会改变.

According to the length of the TableViewController1 cell's string, the back bar button's length also get changing.

是否可以固定后退按钮的宽度?我真的需要这个,因为我想捕获 TableViewController2 导航栏的 titleView 的点击事件.

Is it possible to fix the width of the back bar button? I really need this, because I want to capture the tap events of the TableViewController2 navigation bar's titleView.

后退按钮的宽度会影响 titleView 的宽度.因此,我找不到 titleView 的范围.还是有其他方法可以找到导航栏的titleView的bounds值?

Back bar button's width affects the titleView's width. So I can not find the bounds of the titleView. Or is there any other way to find the bounds value of a titleView of Navigation bar?

推荐答案

是否可以固定后退按钮的宽度?

Is it possible to fix the width of the back bar button?

据我所知您无法编辑此按钮.

As far as I know you can not edit this button.

将其子类化是一种方法,或者您可能希望从以前的viewController中截断标题.另外,您可能希望用普通的 UIBarButtonItem 替换为:

Subclassing it would be the way to go, or you might want to truncate the title from the previous viewController. Alternatively you might want to replace with with a normal UIBarButtonItem like so:

- (void) viewDidLoad
{
    [super viewDidLoad];
    self.title = @"shortTitle.";

    UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back"
                            style:UIBarButtonItemStyleBordered
                            target:nil
                            action:nil];

    self.navigationItem.backBarButtonItem = backButton;
    [backButton release];
 }

这篇关于如何在iPhone中更改UINavigationController的后退按钮的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆