9

我有 iPhone 应用程序使用两种语言(阿拉伯语/英语)的故事板我如何从阿拉伯语本地化故事板切换到英语故事板而无需更改语言 iPhone 设置(在运行时)

4

1 回答 1

8

我已经解决了您可以按照以下代码执行此操作:

 UIStoryboard *storyBoard;
 if ([language isEqualToString:@"ar"]) {
   lan = [[NSLocale preferredLanguages] objectAtIndex:0];
   storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone5Arabic" bundle:bnd];
 }
 else if([language isEqualToString:@"en"]) {
    NSLog(@"DDD ");
    lan = [[NSLocale preferredLanguages] objectAtIndex:20];
    storyBoard = [UIStoryboard storyboardWithName:@"MainStoryboard_iPhone5English" bundle:bnd];
 }
 NSBundle *bnd = [NSBundle bundleWithPath:[[NSBundle mainBundle]pathForResource:lan ofType:@"lproj" ]];



UIViewController *initViewController = [storyBoard instantiateInitialViewController];
[self.window setRootViewController:initViewController];
于 2013-01-12T05:54:58.497 回答