Universal iPad/iPhone XIBs - Xcode 4

前端 未结 6 1019
忘了有多久
忘了有多久 2021-02-06 18:50

I want to make a universal app which has two different XIB files. One for iPhone, and one for iPad. They use the same code, just different UIs. How would I create a \"universal\

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-06 19:36

    Create a Macro like so:

    #define IS_IPAD ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad)
    

    The name your XIBs so that you can do this:

    self.viewController = [[ViewController alloc] initWithNibName:IS_IPAD?@"ViewController~iPad":@"ViewController" bundle:nil];
    

提交回复
热议问题