Using constraints in Objective-C automatic layouts to support RTL languages

I have an application in iOS that I am trying to localize for RTL. Obviously, the layout should match the language.

To get started, I'm trying to make buttons at the bottom of one screen to change their order when I open the application using a set of rtl language settings.

I use auto-cars, and I added restrictions between the buttons and the view relative to the final / leading horizontal view with the main view of the screen, which I should understand. The drag-n-drop blue line method is used to create constraints. In addition, I used the following code in my main part, as described in another thread:

#if TARGET == TARGET_AR NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults]; [defaults setObject:[NSArray arrayWithObject:@"ar-SA"] forKey:@"AppleLanguages"]; [defaults synchronize]; #endif 

This still does not work, and the buttons remain where they were. Any suggestions on how to solve this?

thanks

+4
ios autolayout
source share
2 answers

I do not know where you have a recommendation to use a macro to define a locale, but this is absolutely wrong.

What you miss most is the actual localization of RTL (great that you use Base!). Select the project file in the file navigator and you will see something like this:

What you need to do is add the actual localization of RTL. Therefore, click the β€œ+” above the Use basic internationalization check box and select Arabic (ab) from the pop-up menu, and then continue in the sheet that appears. If you create and run your application on a phone where Arabic is preferred, restrictions should roll over as you expect!

+1
source share

I believe that the right way to do this is to have separate storyboards for each locale so that you not only set the text direction (RTL or LTR), but also use different languages ​​for different user interface elements. You will obviously need to include IBOutlets and IBActions for each storyboard, but it would be more efficient and easier to implement what you offer. Good luck

-2
source share

All Articles