1

Please advice how to change all the app programatically to right to left. from iOS 9 apple set the hebrew / arbic region as left to right (mirroring).

Please advice if there is any option to change this ?

Regards Yakir.

Yakir Sayada
  • 171
  • 1
  • 11

3 Answers3

2

Change the interface language to English. Currently it is the only way (unless apple will get convinced it was a bad idea)

Edit: If you want your app to behave "English only" - you can force the locale in the code: In AppDelegate add to didFinishLaunchingWithOptions:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
        NSArray *languages = [[NSUserDefaults standardUserDefaults] objectForKey:@"AppleLanguages"];
        if (![[languages firstObject] isEqualToString:@"en"]) {
            [[NSUserDefaults standardUserDefaults] setObject:@[@"en"] forKey:@"AppleLanguages"];
            [[NSUserDefaults standardUserDefaults] synchronize];
        }
}
Boaz
  • 4,864
  • 12
  • 50
  • 90
1

In addition to the answer of Boaz - It might be better and safer to place this code in the main.m file instead of in the didFinishLaunching method. (don't have enough Rep. to add this as a comment the the original answer)

And... You don't need to get the array of languages/check the first language, you can simply set it to be "en":

NSUserDefaults * defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[NSArray arrayWithObject:@"en"] forKey:@"AppleLanguages"];
[defaults synchronize];
MatanGold
  • 739
  • 10
  • 18
0
if(OS_GREATER_THAN_OR_EQUALTO(@"9.0"))
{
    if(RightToLeftLanguage)
    {
        [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
    }
    else
    {
        [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
    }
}

"[[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];" this statement enforce the view to be rendered in right to left mode without considering your app or device language. Make sure call this statement in viewDidLoad.

vipin bansal
  • 878
  • 11
  • 10