How can i load the different xibs for single class depends on current device in iOS?

后端 未结 3 429
情歌与酒
情歌与酒 2021-01-23 05:50

I have the complete code in view controller. So, i need to display the same output in iPad,iPhone and iPod. So, am using single view controller for processing data.For this pur

3条回答
  •  [愿得一人]
    2021-01-23 06:38

    This is very simple when you create a universal app, itself it will give the code check the device type and load particular xib.

    for example

     if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
            self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPhone" bundle:nil] autorelease];
        } else {
            self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController_iPad" bundle:nil] autorelease];
        }
    

提交回复
热议问题