ShurupuS
ShurupuS

Reputation: 2923

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:

enter image description here

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:

enter image description here

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.

enter image description here

Upvotes: 5

Views: 1527

Answers (1)

Ganapathy
Ganapathy

Reputation: 4614

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 :

enter image description here

Upvotes: 7

Related Questions