我正在创建一个简单的 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];
我的应用程序在此行崩溃:
我在 iPhone 6+ 上运行,我的 iOS 版本是 8.3 Xcode 版本 7.1
我记得在 iOS 9.1 上运行这段代码并且它有效。
更新
我刚刚用模拟器 iOS 8.3 iPhone 6 测试了这个,它可以工作。
最佳答案
对于 iOS 8.3,您可以按照以下方式执行以下操作:
https://github.com/BradLarson/GPUImage/issues/2041
在 GPUImageContext.m
中的方法 + (BOOL)supportsFastTextureUpload
中执行如下操作:
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);
}
希望对你有帮助:)
关于iOS - 无法以编程方式创建GPUImageView?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36977846/