Created
November 12, 2014 11:20
-
-
Save priore/4725304d15d417d42884 to your computer and use it in GitHub Desktop.
Loading the XIB dependent on the device
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // 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