Search code examples
iosiphoneloadnibnamed

iOS 6 loadNibNamed loads nib of iphone5 in 3.5 inch phones


I have a UIView subclass ( PopupView ) and two xbis for it: PopupView.xib and PopupView~iphone5.xib .

When I call the xib:

    if ( screenHeight >= 568 ) {
        subviewArray = [[NSBundle mainBundle] loadNibNamed:@"PopupView~iphone5" owner:self options:nil];
    } else {
        subviewArray = [[NSBundle mainBundle] loadNibNamed:@"PopupView" owner:self options:nil];
    }

In iOS 7 when testing with 3.5inch phone it loads the correct PopupView.xib and with 4inch phone it loads PopupView~iphone5.xib. But when testing with iOS 6 and 3.5 inch phone, althought the code passes from the "else" statement and theoritically it loads the PopupView.xib , it actually returns the iphone 5 xib ( the view diplayed is the one designed for iphone5 ) and the loaded view's height is 548, not 480.

Any suggestions?


Solution

  • Fixed. All I needed was to Clean Full build and also delete the app from the simulator and rebuild. Hope this case helps someone other who faces a similar problem and does not remember to clean his project.