Switching between localized storyboard at runtime

我是研究僧i 提交于 2019-12-09 04:21:40

问题


I have iPhone application using storyboard with two language (Arabic / English) how i can switch from Arabic localization storyboard to English storyboard without need to change language iPhone settings (At run time)


回答1:


I have resolved you can do it as the following below code :

 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];


来源:https://stackoverflow.com/questions/14259674/switching-between-localized-storyboard-at-runtime

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!