There are several topics here with the same error.
The cause of my error is:
When I create my ViewController’s instance by:
HomepageViewController *homePageViewController = [[HomepageViewController alloc] initWithNibName:@"HomepageViewController" bundle:nil];
Everything is fine. But I need localization.
So I am calling:
NSString *path= [[NSBundle mainBundle] pathForResource:[self language] ofType:@"lproj"];
NSBundle *languageBundle = [NSBundle bundleWithPath:path];
HomepageViewController *homePageViewController = [[HomepageViewController alloc] initWithNibName:@"HomepageViewController" bundle:languageBundle];
Then I cannot see the png images in the simulator getting “image referenced from a nib in the bundle with identifier “(null)” Error” What causes this error?
If you do localization in the recommended way, the code in your first code example should work as is. Behind the scenes, the localized
.lprojfolder will be examined and the XIB will be loaded from there if found. So you don’t need to try to build a path to a localized.lprojfolder yourself as you are doing in your second code sample!I’m not sure if that’s the cause of the issue you are having with png files, though. Have you verified that images are OK when you open the localized XIBs in XCode? Maybe one of your localized versions simply contains a reference to a file that has since been removed.