12

When setting your device to a Right-To-Left language, iOS reverses the order of items.

For example in a UITableViewCell set with Auto-Layout: I have an avatar image on the left and some text aligned right from it that fills up the rest of the cell. In Arabic my avatar is on the right and my label is on the left.

Is there a way to prevent iOS from doing this on certain views, or is there a general setting defining whether or not it can be reversed?

Jovan
  • 2,640
  • 2
  • 24
  • 34

2 Answers2

9

For Xcode6 and iOS8 you can uncheck Respect language direction for the horizontal constrains like below:

enter image description here

Tarek Hallak
  • 18,422
  • 7
  • 59
  • 68
  • is there any shortcut way to disable from all xib or storyboard. it is very difficult to set each constraint leading and trailing constraints. – Ayaz Nov 23 '15 at 08:11
  • @null I have tried LTR to RTL and I am able to mirror my view by using base Internationalization. but the issue I am facing is The values I ahve entered in the Main.strings (Arabic) storyboard its not coming. Can you please help me on this? – Arbaz Shaikh Sep 30 '16 at 12:35
5

You can set the 'direction' property of a spacing layout to "Left to Right" instead of the default: "Leading to trailing". This way the views will not be mirrored in RTL languages.

Unfortunately, you have to set this for every constraint of the views you don't want mirrored. Constraints added with code can be set this way: [self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"H:|-0-[_photoView]-0-|" options:NSLayoutFormatDirectionLeftToRight metrics:nil views:views]];

Jovan
  • 2,640
  • 2
  • 24
  • 34
  • +Up vote to show me right direction. And can you please explain bit more. where i can get "Direction" property in XIB. can you attached screen short if possible. – Ayaz Nov 23 '15 at 09:15
  • You can see this in the screenshot from the other answer above – Jovan Nov 23 '15 at 10:16
  • as per above screen short i need to change every constraint. i their any default way to change once and it will work on hole XIB??? – Ayaz Nov 23 '15 at 11:18
  • There is no such thing that i know if. You could try opening the xib file in a text editor and do a find & replace as suggested in this post: http://stackoverflow.com/questions/19916926/disable-autolayout-localization-behavior-rtl-right-to-left-behavior – Jovan Nov 23 '15 at 14:30