How do I run a universal app on the iPhone 3.1.3 simulator?

你说的曾经没有我的故事 提交于 2019-12-02 17:20:14

Quite the opposite. A universal app runs the same binary on iPhone and iPad so you cannot use conditional compilation to differentiate between the two version. But you need to use the macro Apple cites in the documentation:

if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) {
    // iPad-specific code
} else {
    // iPhone-specific code
}

I use this C function to help keep the code concise:

BOOL isPad() {
    return (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad);
}

Another thing I do, when I have different xib files for iPhone vs iPad. I have a stripPadSuffixOnPhone() function that helps keep the code simpler:

// Load/create the Delete table cell with delete button
self.deleteCell = [Utilities loadNib:stripPadSuffixOnPhone(@"DeleteCell~ipad") 
                           ClassName:@"DeleteCell" 
                   Owner:self];

Things like that can make coding more straightforward and a lot less conditionals. Still have to test everything twice though.

Here's what works for me:

  1. Build your app using SDK 3.2.
  2. Switch the active SDK to iPhone Simulator 3.1.3 (or whatever).
  3. From the Run menu select Debug (not Build and Debug).

The binary built under 3.2 will be installed in the 3.x simulator without rebuilding. When you are finished don't forget to set your active SDK back to 3.2.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!