I use these methods
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObject:@"ar"] forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults] synchronize];
to force my app to change its localization during run time (when the user taps a button which simple calls these methods) and it works perfectly, however, these methods are not sufficient to switch the whole XIB to the new language (which is in my case, Arabic language), giving that I have one XIB named HomeViewController.xib
that opens as a directory in XCode, a directory of two files: HomeViewController.xib (English)
and HomeViewController.xib (Arabic)
each file has its own layout according to language (for ex. Arabic xib has right to left controls layout ..), i've tried to call removeFromSuperView
for every control on the current controller and then call addSubView
for the controls, but nothing has changed, the app still displays the english XIB.
how can I let my app to change its XIB to the correct localized one at run time when that language button tapped.
p.s. when I change the whole simulator localization in system settings, the app works as expected, i.e. it displays the correct localized XIB.