我有两个故事板,一个用于LTR(从左到右脚本,如英语,德语等),另一个用于阿拉伯语RTL(从右到左脚本)。我想根据所选的用户语言在这两个故事板之间切换。目前我在AppDelegate.m文件中执行此代码:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
NSString *typeN = [[NSLocale preferredLanguages] objectAtIndex:0];
//NSBundle *myBundle= [[NSBundle alloc] init];
if([typeN compare:@"ar"] == NSOrderedSame){
UIStoryboard *us = [UIStoryboard storyboardWithName:@"RtlStoryboard" bundle: nil];
FirstViewController *myStoryBoardInitialViewController = [us instantiateInitialViewController];
myStoryBoardInitialViewController.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
NSLog(@"arabic- RTL");
}
else {
UIStoryboard *ms = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle: nil];
FirstViewController *myStoryBoardInitialViewControl = [ms instantiateInitialViewController];
myStoryBoardInitialViewControl.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
NSLog(@"english- ENG");
}
这是正确的做法吗,虽然对于阿拉伯语[typeN比较:@“ar”]如果块正在执行但它仍在加载LTR storyBoard。两个故事板的视图控制器也是相同的,因为代码逻辑是相同的,它只是屏幕格式不同。请提供有关此问题的指示或详细说明。