Xcodeを使用して2つのXIBが含まれている単純なアプリケーションがあります(ファイルインスペクタペインでローカライズされています)。 アラビア語XIBはimageView
内の画像が含まれており、また英語XIB:私はアプリが一つの小さな問題を除いて、完璧に動作し、アプリケーションの言語を切り替えると、他のローカライズXIBに切り替えるには、ルートビューコントローラxib
に二つのボタンを配置していますimageView
内の画像、バンドルのペン先から参照される画像を読み込むことができません
1)私はアラビア語に英語から言語を切り替えると、アラビア語XIBは場所ではなく、画像
せずに来るが含まれています2)及びその逆、私はアラビア語から英語
3に切り替えたとき)でもアプリで画像が表示されない起動: Xcodeはアプリケーションをクラッシュすることなくコンソールでこれらの3例では、このエラーを生成します。
2011-12-27 12:48:30.412 LangSwitch[4903:f803] Could not load the "image1.png" image referenced from a nib in the bundle with identifier "(null)"
didFinishLaunchingWithOptions
方法コード:
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(lang:) name:@"Lang" object:nil];
// Override point for customization after application launch.
// Set the navigation controller as the window's root view controller and display.
NSString* str = [[[NSUserDefaults standardUserDefaults]valueForKey:@"AppleLanguages"] objectAtIndex:0];
NSBundle* bnd = [NSBundle bundleWithPath:[[NSBundle mainBundle]pathForResource:str ofType:@"lproj"]];
RootViewController* cont = [[RootViewController alloc]initWithNibName:@"RootViewController" bundle:bnd];
self.window.rootViewController = cont;
[self.window makeKeyAndVisible];
とlang
セレクタコード:
- (void)lang:(NSNotification*)sender{
//NSLog(@"%@",[sender object]);
[[NSUserDefaults standardUserDefaults] setObject:[NSArray arrayWithObjects:[sender object],nil] forKey:@"AppleLanguages"];
[[NSUserDefaults standardUserDefaults]synchronize];
NSString* str = [[[NSUserDefaults standardUserDefaults]valueForKey:@"AppleLanguages"] objectAtIndex:0];
NSBundle* bnd = [NSBundle bundleWithPath:[[NSBundle mainBundle]pathForResource:str ofType:@"lproj"]];
RootViewController* cont = [[RootViewController alloc]initWithNibName:@"RootViewController" bundle:bnd];
self.window.rootViewController = cont;
[self.window makeKeyAndVisible];
}
と私は上記の記述てるものを含んでいhere is the sample app。あなたがこの問題を解決するのに役立つなら、私はあなたにとても感謝しています。
は、事前にあなたをとても感謝...
で、私は4つの画像(アラビア語の場合は2)と英語の場合は2つを作成し、4つの画像をローカライズしています。どうもありがとうございます。 – JAHelia