如何在 iPhone 3.1.3 模拟器上运行通用应用程序?
我正在开发一款新应用程序,我希望它能够在 iPhone 和 iPad 上通用。我从“创建基于窗口的应用程序”向导开始,它在“iPhone”和“iPad”组中创建了单独的应用程序委托。由于我已经非常熟悉 iPhone 开发,所以我完成了项目的这一部分,现在我准备好做一些 iPad 的东西了。
所以...我首先向我的 iPad delegate 添加 UISplitViewController,将 Active SDK 切换到 3.2,然后它就可以工作了!但是当我切换回 3.1.3 并尝试在模拟器中运行它时,Build and Go 失败了。首先,我看到:
...路径.../iPad/AppDelegate_Pad.h:13:错误:“UISplitViewController”之前预期有说明符限定符列表
我已将基本 SDK 设置为 3.2,将部署目标设置为 3.1.3。我想这就足够了。但我还在文档中找到了这种方法来进行条件编译:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
MyIPadViewController* vc;
// Create the iPad view controller
#else
MyIPhoneViewController* vc;
// Create the iPhone view controller
#endif
那么我需要在所有地方都这样做吗?看起来需要添加大量代码(无论如何我都会在短时间内删除 4.0 的代码),所以我觉得我一定做错了什么。而且,我什至不知道这对于 @property 或 @synthesize 声明之类的东西是如何工作的。
tl; 问题的博士版本 - 我是否错过了某个地方的设置?
I'm working on a new app that I want to be universal for the iPhone and iPad. I started out with the "Create a Window-based app" wizard, and it created separate app delegates in "iPhone" and "iPad" groups. Since I already was quite familiar with iPhone dev, I did that part of my project, and now I'm ready to do some iPad stuff.
So... I started out by adding a UISplitViewController to my iPad delegate, switch the Active SDK to 3.2, and it works! But when I switch back to 3.1.3, and try to run it in the simulator, Build and Go fails. For starters, I see:
...path.../iPad/AppDelegate_Pad.h:13: error: expected specifier-qualifier-list before 'UISplitViewController'
I've got my Base SDK set to 3.2 and my Deployment Target set to 3.1.3. I thought that was enough. But I also have found in the documentation this method to conditionally compile:
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 30200
MyIPadViewController* vc;
// Create the iPad view controller
#else
MyIPhoneViewController* vc;
// Create the iPhone view controller
#endif
So do I need to do this everywhere? It seems like an awful lot of code to add (that I'll be getting rid of in a short time for 4.0 anyway) so I feel like I must be doing something wrong. And, I don't even have any idea how this works for things like @property or @synthesize declarations.
tl;dr version of the question - did I miss a setting somewhere?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我使用这个 C 函数来帮助保持代码简洁:
当我有针对 iPhone 和 iPad 的不同 xib 文件时,我做的另一件事是。我有一个 stripPadSuffixOnPhone() 函数,可以帮助保持代码更简单:
这样的事情可以使编码更简单并且条件更少。但仍然需要对所有内容进行两次测试。
I use this C function to help keep the code concise:
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:
Things like that can make coding more straightforward and a lot less conditionals. Still have to test everything twice though.
恰恰相反。通用应用程序在 iPhone 和 iPad 上运行相同的二进制文件,因此您无法使用条件编译来区分这两个版本。但你需要使用苹果在文档中引用的宏:
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:
以下是对我有用的方法:
3.2 下构建的二进制文件将安装在 3.x 模拟器中,无需重建。完成后,请不要忘记将活动 SDK 设置回 3.2。
Here's what works for me:
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.