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

标签 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 测试了这个,它可以工作。

最佳答案

对于 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/

相关文章:

iphone - 在应用程序运行时阻止 Iphone iOS 中的调用和短信

objective-c - WMV 转换器失败 FFMpeg

ios - 如果我的 UIViews 边框颜色 alpha 小于 1.0,如何避免颜色重叠?

ios - 如何使用 GPUImage 启用 64 位支持

ios - 使用 GPUImage 将两个视频与色度键混合

ios - GPUImage - MovieWriter,在 "setCompletionBlock"之后的一段时间内没有任何反应

ios - 符合 Swift 中的 NSMutableCopying 吗?

ios - Cloudkit 的 NSPredicate 匹配字符串

ios - iOS 5 中的 UIView 使用 Storyboard不会在 iPad 设备旋转时旋转内容

ios - 如何设置单元格在 UICollectionView 上的位置