문제

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];
도움이 되었습니까?

해결책

I was fix it with some trick =)

[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:@{UITextAttributeFont: [UIFont systemFontOfSize:0.1]}
                                                                                        forState:UIControlStateNormal];
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top