简体   繁体   中英

UINavigationBar back button title is hidden when the bar title is too long in iOS7

I have a problem and can't solve it. I'll try to describe the issue, so:

when the title of the UINavigationBar is not so long - the situation is like this:

在此输入图像描述

but if the title of the bar contains more characters - it hides the title of the back button as u can see on the next screenshot:

在此输入图像描述

Is it a standard UINavigationBar behaviour in iOS7? May be there are some ways to solve this? Anyway in iOS6 the situation is much better - there I can't find any problem like this.

在此输入图像描述

Simple fix:

Create one view with label and set that view as a title view to the navigation controller

// creating title view 
UIView *titleView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 40)];
    // Adding label with custom frame
    UILabel *labelForTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 200, 30)];

    [labelForTitle setCenter:titleView.center];
    [labelForTitle setText:@"sfdfagd ggjhdgfjhadsgfjasgdhfgasdjfgajsdgfjashgdjhfasjdfsadjgfhsadghf"];

    [titleView addSubview:labelForTitle];

     // setting title view for the navigation controller.
    [self.navigationItem setTitleView:titleView];

output will be like this :

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM