11

I have an app that supports 2 languages, English and Arabic. English is left to right & Arabic is right to left.

I have a controller named LanguageViewController. There are two buttons in it: Arabic & English. When a user clicks on "Arabic" the language of my App changes from English to Arabic. I use auto layout in my project.

When the language is changed, I expect my object's position be mirrored at the same time. but it doesn't & when I close my App and run again, the object's position are mirrored correctly.

In Question: How to force "Respect Language Direction" from RTL to LTR and vice versa @Raz had the same problem. but I don't want to build a new storyBoard. When the language is changed from En to Ar and you quit the App the value of userInterfaceLayoutDirection is change from UIUserInterfaceLayoutDirectionLeftToRight to UIUserInterfaceLayoutDirectionRightToLeft. I used NsLog to see the value of userInterfaceLayoutDirection. When I press the "Arabic" button the value doesn't change,bbut when I run again the value is changed. My question is how to force change userInterfaceLayoutDirection without quitting and without loading new storyboard?

Community
  • 1
  • 1
amin akbarzade
  • 227
  • 2
  • 13

1 Answers1

1

How exactly are you changing the application's preferred language with your buttons?

The userInterfaceLayoutDirection of an app is set once at launch time. There is currently no way to change it while an app is running.

lensovet
  • 5,490
  • 2
  • 23
  • 19
  • so. what to do when the user change the language in my application setting (not ios setting). i dont want to force user to quit my app and run again. if user dont quit my app, the direction of constraint for buttons and labels doesnt change. and this in not my case. – amin akbarzade May 17 '15 at 07:28
  • There is no way to do what you are trying to accomplish at the moment. – lensovet May 17 '15 at 11:09
  • Out of curiosity, is in-app language switching something that your users want? Why not just always run in the preferred system-wide language? – lensovet May 17 '15 at 11:10