Search code examples
objective-cios6uinavigationcontrolleruinavigationitemtitleview

Strange Bug in iOS 6 UINavigationController


I have found a strange bug in ios. When I use UINavigationController and push other controllers, the titleView shifted to the right so much as how many controllers was pushed

It's looks like this:

enter image description here

My code is simple:

self.navigationItem.title = @"Test Title";

In the second case, controller has 5th in viewControllers stack. The controller in the all cases is same.

I was using the appearance for UIBarButtonItem, in my AppDelegate.

[[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(-1000, 0) forBarMetrics:UIBarMetricsDefault];

Solution

  • I was fix it with some trick =)

    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{UITextAttributeFont: [UIFont systemFontOfSize:0.1]}
                                                                                            forState:UIControlStateNormal];