iOS: disable UI mirroring in XIB

纵然是瞬间 提交于 2019-12-05 00:45:17

问题


in iOS 6 there's a new "feature" that mirrors the UI elements in the xib file if the user is on right-to-left locale (hebrew, arabic). (http://developer.apple.com/library/ios/#documentation/miscellaneous/conceptual/iphoneostechoverview/iPhoneOSTechnologies/iPhoneOSTechnologies.html)

It completely messes up my interface.

Is there a way to disable it without disabling auto-layout?


回答1:


Horizontal constraints have the "Direction" option in Interface Builder. By default it's set to "Leading to Trailing" which causes the mirroring. You can set it to "Left to Right" to disable the mirroring.

Note, changing all the constraints by editing storyboard/xib files causes exceptions or messed up layout, it seems that Interface Builder creates / changes some additional constraints when changing the direction setting.

So the faster way I found to change the existing xib/storyboard, is to select all the constraints with the "Leading to Trailing" set, change them all together to "Left to Right" and then check if some new horizontal constraints were automatically created - their direction should be changed to "Left to Right" as well.




回答2:


Followed by the solution of @silyevsk - here is a quick method worked for me to fixed the UI mirroring: Open your xib file in text editor (xcode/textedit/atom etc.) Using the replace tool, replace the following:

firstAttribute="trailing" with: firstAttribute="right"

secondAttribute="trailing" with: secondAttribute="right"

firstAttribute="leading" with: firstAttribute="left"

secondAttribute="leading" with: secondAttribute="left"

Worked for me and saved many struggling hours with IB.




回答3:


I don't know why this answer has been deleted, it works perfectly!



来源:https://stackoverflow.com/questions/14724767/ios-disable-ui-mirroring-in-xib

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!