简体   繁体   English

导航栏标题如何仅在一个特定视图上不能居中对齐?

[英]How is it possible for the Navigation Bar title to not be aligned in centre only on one specific view?

In my application I have 9 different menu items and all of them have the navigation bar title centred. 在我的应用程序中,我有9个不同的菜单项,并且所有菜单项的导航栏标题均居中。 There is only one view in which the title it seems to be aligned right (see screen 2 attached). 只有一个视图的标题似乎正确对齐(请参见随附的屏幕2)。 How is this possible? 这怎么可能?

The screen 1 & 2 that I have attached are two consecutive screens, in which the 1st title is ok and then wrong. 我已附加的屏幕1和2是两个连续的屏幕,其中第一个标题正确,然后又错误。 Any suggestions? 有什么建议么?

屏幕2 屏幕1

Okay after having tried everything I realised that I had used the code below in the app delegate to hide the title of the back button: 好了,在尝试了所有内容之后,我意识到我已经在应用程序委托中使用以下代码隐藏了后退按钮的标题:

 let barAppearace = UIBarButtonItem.appearance()
    barAppearace.setBackButtonTitlePositionAdjustment(UIOffsetMake(0, -60), forBarMetrics:UIBarMetrics.Default)

As a result, my actual back title which was longer that all the other titles in the rest of my views (this is why all my other views worked fine) was still there but hidden , pushing the main nav title to the right as it was too long. 结果,我的实际后标题比我其余视图中的所有其他标题更长(这就是我所有其他视图都能正常工作的原因),该标题仍然存在但被隐藏了 ,从而主导航标题向右太长。

Therefore to avoid this issue ensure that you have not hidden the title of the back button. 因此,为避免此问题,请确保您没有隐藏“后退”按钮的标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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