How are XIBs loaded for localized apps?

前端 未结 4 768
情书的邮戳
情书的邮戳 2021-01-02 11:23

I found after a couple of days of successfully running and debugging localized apps on the Simulator it (or the XCode deployment process) got into a state where, if the Simu

相关标签:
4条回答
  • 2021-01-02 11:43

    I had this issue recently when I had a english version of the nib but didn't localize it for any of the other languages (MyNib was in en.lproj). The simulator was only looking in the other language directory (da.lproj, de.lproj, etc.) for MyNib and not falling back to the english version if not found. I fixed it by removing the english localization for the nib. That caused it to be the in the app bundle's root with the other resources instead of in en.lproj. After that everything worked perfectly.

    I was a bit confused by it since I thought the localization system checked through all of the languages in the user's preferred order with english usually being used by the dev as the catch all. I'm not sure if this is a change in loading behavior or a simulator bug (I never tried on device). I'm guessing it's the latter, but I don't know for sure. This reminds me though that I need to submit a bug report on it.

    0 讨论(0)
  • 2021-01-02 11:49

    I was able to solve this problem by simply restarting xcode. =/

    0 讨论(0)
  • 2021-01-02 12:05

    Had the same symptom but different root cause I'd like to share. I removed the localization as McCygnus hinted at (thanks for that) but still got the same exception on iPads, only. It turned out that my Info.plist file contained a link to an iPad specific main window nib file (MainWindow-iPad.nib). After removing that, everything worked.

    0 讨论(0)
  • 2021-01-02 12:10

    if you are using

    [[Class alloc] initWithNibName:@"aNibName" bundle:nil];  
    

    change it to

    [[Class alloc] initWithNibName:@"aNibName" bundle:[NSBundle mainBundle]];
    
    0 讨论(0)
提交回复
热议问题