如何在 iPhone 3.1.3 模拟器上运行通用应用程序?

发布于 2024-08-31 03:39:04 字数 861 浏览 3 评论 0原文

我正在开发一款新应用程序,我希望它能够在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

谁对谁错谁最难过 2024-09-07 03:39:04

我使用这个 C 函数来帮助保持代码简洁:

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

当我有针对 iPhone 和 iPad 的不同 xib 文件时,我做的另一件事是。我有一个 stripPadSuffixOnPhone() 函数,可以帮助保持代码更简单:

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

这样的事情可以使编码更简单并且条件更少。但仍然需要对所有内容进行两次测试。

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.

迟月 2024-09-07 03:39:04

恰恰相反。通用应用程序在 iPhone 和 iPad 上运行相同的二进制文件,因此您无法使用条件编译来区分这两个版本。但你需要使用苹果在文档中引用的宏:

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

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
}
离旧人 2024-09-07 03:39:04

以下是对我有用的方法:

  1. 使用 SDK 3.2 构建您的应用程序。
  2. 将活动 SDK 切换到 iPhone Simulator 3.1.3(或其他版本)。
  3. 从“运行”菜单中选择“调试”(而不是“构建和调试”)。

3.2 下构建的二进制文件将安装在 3.x 模拟器中,无需重建。完成后,请不要忘记将活动 SDK 设置回 3.2。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文