Objective-C Tips & Trick - Prioregroup.com
[Objective-C] Loading the XIB dependent on the device
       
back

// Loading the XIB dependent on the device
//
// 1. create your viewcontroller's named MyViewController~ipad.xib and MyViewController~iphone.xib
//
// 2. inizialize your class with MyViewController myvc = [[MyViewController alloc] initWithDefaultNib];
//

- (id)initWithDefaultNib
{
    NSString *nibName =[[[[[NSBundle mainBundle] pathForResource: NSStringFromClass([self class]) ofType:@"nib"] componentsSeparatedByString:@"/"] lastObject] stringByReplacingOccurrencesOfString:@".nib" withString:@""];
    if (self = [super initWithNibName:nibName bundle:nil]) {
        
    }
    
    return self;
}






Copyright © 1996-2018 Centro Studi Informatica di Danilo Priore. All rights reserved. P.I.10149810581.
prioregroup.com