【问题标题】:Custom CIKernel and iOS7自定义 CIKernel 和 iOS7
【发布时间】:2015-01-26 06:02:23
【问题描述】:

我有一个 iOS 项目,它支持同时运行 iOS 7 和 8 的设备(项目部署目标:7.0),我最近开始使用 iOS 8 中引入的新 API 实现自定义 CIKernel。

虽然代码在每个 iOS 8 设备上编译和运行都没有问题,但每次我尝试在 iOS 7 设备上运行它时都会收到此错误:

dyld: Symbol not found: _OBJC_CLASS_$_CIColorKernel
  Referenced from: /var/mobile/Applications/...
  Expected in: /System/Library/Frameworks/CoreImage.framework/CoreImage
 in /var/mobile/Applications/...

产生错误的代码是这个:

kernel = [CIColorKernel kernelWithString:kernelStr];

kernelWithString: 方法是在 iOS8 中引入的,正如 CIKernel.h 声明的那样:

__OSX_AVAILABLE_STARTING(__MAC_10_10, __IPHONE_8_0);

所以我的问题是:如何让应用程序在 iOS 7 和 8 设备上运行,并且只为 iOS 7 设备禁用我的自定义 CIKernel 功能?那可能吗?

请注意,我已将项目设置中的 CoreImage.framework 从“必需”更改为“可选”,并且该应用程序在 iOS7.0 设备上运行,但老实说,感觉真的很糟糕。

我也尝试过预处理器命令:__IPHONE_OS_VERSION_MIN_REQUIRED__IPHONE_OS_VERSION_MAX_ALLOWED,但它们仅在编译时有用。

有什么线索吗?

【问题讨论】:

    标签: ios objective-c core-image


    【解决方案1】:

    试试这个:

    Class colorKernelClass = NSClassFromString(@"CIColorKernel");
    kernel = [colorKernelClass kernelWithString:str];
    

    【讨论】:

      【解决方案2】:

      所以我的问题是:如何让应用程序在 iOS 7 和 8 设备上运行,并且只为 iOS 7 设备禁用我的自定义 CIKernel 功能?这可能吗?

      您可以像这样在运行时检查操作系统的版本:

      NSString *osVer = [[UIDevice currentDevice] systemVersion]
      

      这提供了一个字符串,您可以解析和提取主要版本...

      【讨论】:

      • 是的,我也尝试过,但错误不断出现。
      猜你喜欢
      • 2013-04-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-05-11
      • 1970-01-01
      • 2021-09-02
      • 2013-09-29
      相关资源
      最近更新 更多