priore

Loading the XIB dependent on the device

Jul 9th, 2014
720
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Loading the XIB dependent on the device
  2. //
  3. // 1. create your viewcontroller's named MyViewController~ipad.xib and MyViewController~iphone.xib
  4. //
  5. // 2. inizialize your class with MyViewController myvc = [[MyViewController alloc] initWithDefaultNib];
  6. //
  7.  
  8. - (id)initWithDefaultNib
  9. {
  10.     NSString *nibName =[[[[[NSBundle mainBundle] pathForResource: NSStringFromClass([self class]) ofType:@"nib"] componentsSeparatedByString:@"/"] lastObject] stringByReplacingOccurrencesOfString:@".nib" withString:@""];
  11.     if (self = [super initWithNibName:nibName bundle:nil]) {
  12.        
  13.     }
  14.    
  15.     return self;
  16. }
RAW Paste Data