我有一个应用程序,可以使用户在运行时从应用程序中切换语言。一切正常,但是当切换到另一种语言时,为该语言加载本地化的Xib,但是该Xib内部没有任何图像。以下是我的代码,用于切换到另一种语言。
NSString* str = [[[NSUserDefaults standardUserDefaults]valueForKey:@"AppleLanguages"] objectAtIndex:0];
NSBundle* bnd = [NSBundle bundleWithPath:[[NSBundle mainBundle]pathForResource:str ofType:@"lproj" ]];
HomeViewController *homeVC = [[HomeViewController alloc] initWithNibName:@"HomeViewController" bundle:bnd];
UINavigationController *localNavigationController = [[UINavigationController alloc] initWithRootViewController:homeVC];
localNavigationController.viewControllers = [NSMutableArray arrayWithObject:homeVC];
localNavigationController.navigationBarHidden = YES;
NSMutableArray *navs = [NSMutableArray arrayWithObject: localNavigationController];
tabBarController.viewControllers = navs;
self.window.rootViewController = tabBarController;
这里是Xcode调试中发生错误的地方。
Could not load the "sahdow.png" image referenced from a nib in the bundle with identifier "(null)"
我很高兴能帮助解决这个问题,这让我花费了很多时间。