Skip to content

Instantly share code, notes, and snippets.

@priore
Created November 12, 2014 11:20
Show Gist options
  • Save priore/4725304d15d417d42884 to your computer and use it in GitHub Desktop.
Save priore/4725304d15d417d42884 to your computer and use it in GitHub Desktop.
Loading the XIB dependent on the device
// 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;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment