2012-02-22 9 views
3

iPhone 앱용으로 현지화 된 이미지가 두 세트 있습니다. 이미지를 어떻게 배치해야합니까? 앱에 어떻게로드 할 수 있습니까?iOS : 현지화 된 이미지 관리

폴더 구조는 다음과 같다 :

For English version: 
/MyApp/en.lproj/Localizable.strings , InfoPList.strings 
/MyApp/en.lproj/*.png (images) 

For Traditional Chinese version: 
/MyApp/zh-Hant.lproj/Localizable.strings , InfoPList.strings 
/MyApp/Resources/*.png (images) 

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults]; 
NSString *locale = [[defaults objectForKey:@"AppleLanguages"] objectAtIndex:0]; 
NSString* path= [[NSBundle mainBundle] pathForResource:locale ofType:@"lproj"]; 
NSBundle* languageBundle = [NSBundle bundleWithPath:path]; 
SomeViewController *vc = [[SomeViewController alloc] initWithNibName:@"SomeViewController" bundle:languageBundle]; 

나는 이미지의 두 세트에 동일한 파일 이름을 사용하고 자동로드하고 싶습니다. 가능한가?

이제 문제가 발생했습니다. 디버그 콘솔에서 다음과 같이 말했습니다.

NSBundle </Users/SomeUser/Library/Application Support/iPhone Simulator/5.0/Applications/1DC22505-1E78-4B5E-A794-DBF72DC786AE/MyApp.app/zh-Hant.lproj> (not yet loaded) 

어떻게 해결할 수 있습니까?

답변

7

왜 언어 번들을 직접 가져 옵니까?

NSString *imageName = NSLocalizedString(@"myimage_jp", @"localized image"); 
UIImage *image = [UIImage imageNamed:imageName]; 

을 그리고 Localizable.strings 파일에 너무 (일본어가 기본 언어로 가정)처럼 그 이미지 이름을 매핑 : 당신은과 같이 이미지 파일 이름을 현지화 할 수 물론

@"myimage_jp" = @"myimage_cn" 

당신 자원 (myimage_jpmyimage_cn)

+0

내가 이미지를 넣어야에서 이미지의 두 버전이해야? 같은 폴더 ('/ MyApp/Resources /'또는'.lproj'에있는 모두)? – Raptor

+1

Resources 폴더에 –

+0

보기 컨트롤러 초기화시 번들을'nil'으로 설정하면 앱을 다시 시작한 후에 이미지가 제대로 작동하고 있습니다. 다시 시작하지 않고도 앱 이미지를 변경할 수있는 방법이 있습니까? – Raptor