2015-09-28 51 views
0

项目在iOS 8设备和模拟器上构建和运行完美。但在iOS 9设备上运行给出错误:无法找到Root.plist。 plist将根据首选语言(英语或普通话)进行选择。错误:升级到iOS后找不到.plist文件9

NSString *path = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"]; 
    path = [path stringByAppendingPathComponent:[[[NSLocale preferredLanguages] objectAtIndex:0] stringByAppendingPathExtension:@"lproj"]]; 
    path = [path stringByAppendingPathComponent:@"Root.plist"]; 

my files in project nav window

回答

0

修正了在iOS的回报 “en” 表示英语和iOS 9返回 “EN-US” 以前的版本问题 [NSLocale preferredLanguages。所以创建的路径是错误的,并且找不到文件

NSString *path = [[NSBundle mainBundle] pathForResource:@"Settings" ofType:@"bundle"]; 
    NSString *lang = [[NSLocale preferredLanguages] objectAtIndex:0]; 

    /*iOS 9 fix as lang for ios 9 returns en-US*/ 
    if ([lang isEqualToString:@"en-US"]) { 
     lang = @"en"; 
    } 

    path = [path stringByAppendingPathComponent:[lang stringByAppendingPathExtension:@"lproj"]]; 
    path = [path stringByAppendingPathComponent:@"Root.plist"]; 
相关问题