在 2.2 设备上使用 iPhone OS 3.0 函数调用代替已弃用的 2.2 函数调用

发布于 2024-08-16 23:08:12 字数 284 浏览 1 评论 0原文

如果我将iPhone应用的Base + Active SDK设置为3.0,部署目标设置为2.2,我可以在2.2设备上使用新版本的功能吗?

例如,UITableViewCell 现在需要使用 [cell.imageView setImage:image] 设置图像,而在 2.2 中,您需要调用 [cell setImage:图片]。在 2.2 设备上使用新的 [cell.imageView setImage:image] 会崩溃吗?

If I set the Base + Active SDK of an iPhone app to 3.0 and the Deployment Target to 2.2, can I use the new versions of functions on 2.2 devices?

For example, UITableViewCell now requires an image to be set using [cell.imageView setImage:image], whereas in 2.2, you'd call [cell setImage:image]. Will using the new [cell.imageView setImage:image] crash on 2.2 devices?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

我还不会笑 2024-08-23 23:08:12

不,你不能在 2.2 上调用 OS 3.0。已弃用的方法至少在 OS 3 中应表现正常。在操作系统中的许多情况下,弃用仅意味着 Apple 推荐使用新方法而不是已弃用的方法;但这些方法将来也可能消失。

您有几个选择:

  1. 只要应用程序和方法实际上在 OS 3.0 上运行,就可以忽略警告。
  2. 进行运行时检查以确定操作系统版本,并调用适当的方法:

    双版本 = [[[UIDevice currentDevice] systemVersion] doubleValue];
    如果(版本>=3.0){
        [cell.imageView setImage:image];
    } 别的 {
        [单元格设置图像:图像];
    }
    

    或者更好:

    if ([cell respondsToSelector:@selector(imageView)]) {
         [cell.imageView setImage:image];
    } 别的 {
         [单元格设置图像:图像];
    }
    

    请注意,使用 ifdef 指令进行编译时检查将不起作用

  3. 删除 OS 2.2 支持。您只以 3.0 为目标也是非常合理的,因为 3.X 的采用率相当高。就我的小型应用程序而言,12 月份,在 2,058 个用户中,有 27 个用户使用 3.0 之前的系统。不用说,此选项会显着减少您的测试需求。

Nope you cannot us OS 3.0 calls on 2.2. Deprecated method should be behave as normal at least in OS 3. Deprecation in many cases in the OS, just means that Apple recommend using new methods rather then deprecated ones; but those methods may disappear in the future too.

You have few options:

  1. Simply ignoring the warnings, as long as app and methods actually work on OS 3.0.
  2. Have a runtime check to determine the OS version, and invoke the appropriate method:

    double version = [[[UIDevice currentDevice] systemVersion] doubleValue];
    if (version >= 3.0) {
        [cell.imageView setImage:image];
    } else {
        [cell setImage:image];
    }
    

    or better yet:

    if ([cell respondsToSelector:@selector(imageView)]) {
         [cell.imageView setImage:image];
    } else {
         [cell setImage:image];
    }
    

    Note that a compile time check, using ifdef directives won't work

  3. Dropping OS 2.2 support. It's quite reasonable for you to only target 3.0 as well, as the uptake of 3.X is quite high. In the case of my small app, in December I had 27 users on pre-3.0 systems out of 2,058 users. Needless to say, this option reduces your testing need significantly.

掩耳倾听 2024-08-23 23:08:12

不可以,您不能在 2.x 设备上使用 OS 3.0 调用。如果您甚至可以在 2.x 设备上安装针对 3.0 的应用程序,我会感到惊讶。

No, you cannot use OS 3.0 calls on a 2.x device. I'd be surprised if you can even install a 3.0-targeted app on a 2.x device.

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