iOS - 无法以编程方式创建GPUImageView?

时间:2016-05-02 08:08:27

标签: ios objective-c gpuimage

我正在创建一个简单的GPUImageView。这是我的代码:

    GPUImageView *gpImageView = [[GPUImageView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    UIImage * image = [UIImage imageNamed:@"placeholder.png"];
    GPUImagePicture * inputImage = [[GPUImagePicture alloc] initWithImage:image];
    [inputImage processImage];
    [inputImage addTarget: gpImageView];
    [self.view addSubview:gpImageView];

我的应用在这一行崩溃了:

enter image description here

我在iPhone 6+上运行,我的iOS版本是8.3 Xcode版本7.1

我记得在iOS 9.1上运行此代码并且它可以运行。

更新

我刚用模拟器iOS 8.3 iPhone 6测试了它,它可以工作。

1 个答案:

答案 0 :(得分:1)

对于iOS 8.3,您可以按照以下方式执行以下操作:

https://github.com/BradLarson/GPUImage/issues/2041

+ (BOOL)supportsFastTextureUpload的方法GPUImageContext.m中执行以下操作:

float version = [[[UIDevice currentDevice] systemVersion] floatValue];
NSString* formattedVersion = [NSString stringWithFormat:@"%.01f", version];
if ([formattedVersion isEqualToString:@"8.3"]) {
  return NO; // https://github.com/BradLarson/GPUImage/issues/2041
} else {
  return (CVOpenGLESTextureCacheCreate != NULL);
}

希望它会有所帮助:)