gpt4 book ai didi

iphone - 在运行时在本地化 Storyboard之间切换

转载 作者:技术小花猫 更新时间:2023-10-29 11:22:03 26 4
gpt4 key购买 nike

我的 iPhone 应用程序使用两种语言(阿拉伯语/英语)的 Storyboard,我如何在无需更改语言 iPhone 设置的情况下从阿拉伯语本地化 Storyboard切换到英语 Storyboard(在运行时)

最佳答案

我已经解决了你可以按照下面的代码来做:

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

关于iphone - 在运行时在本地化 Storyboard之间切换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14259674/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com