Ramkrishna Sharma Ramkrishna Sharma - 1 year ago 162
Objective-C Question

iOS Arabic localization issue in iOS 10

I have developed the application where I need to provide the support for two language English and Arabic. In application there is a setting screen where user can change the language from english to arabic and vice versa.

For more information please find the below screenshot for the same.

And the code which perform the

where I had refreshed the
to update UI.

- (void)updateLanguage {

UIStoryboard *mainStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
UIViewController *vc = [mainStoryboard instantiateViewControllerWithIdentifier:@"MainNavigationController"];
[[UIApplication sharedApplication].keyWindow setRootViewController:vc];

As from
iOS 8
iOS 9
, it works fine and update the UI but in
iOS 10
it does not update the UI. For more information please review the below screenshot.

How I can achieve for update the UI in
iOS 10

Below is the proper UI which need to be updated in
iOS 10

Note : When the application came from background to foreground then it
is working fine.

Answer Source

I found the way how to update the layout based on language selection using UISemanticContentAttribute.

if(IS_OS_10_OR_LATER) {

    if ([[[NSUserDefaults standardUserDefaults] valueForKey:@"Ln"] isEqualToString:@"Ar"])
        [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceRightToLeft];
        [[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];

As I had stored the current language selection in NSUserDefaults and accordingly update the layout.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download