Simeon の答えは機能しますが、アプリケーション内のすべての EAGL ベースのビューの動作が変わります。バッキングを強制する必要があるビューとそうでないビューがあるため、次のように GLKView と CEAGLLayer のサブクラスを作成することで、わずかに異なるソリューションを思い付きました。
@interface RetainedEAGLLayer : CAEAGLLayer
@end
@implementation RetainedEAGLLayer
- (void)setDrawableProperties:(NSDictionary *)drawableProperties {
// Copy the dictionary and add/modify the retained property
NSMutableDictionary *mutableDictionary = [[NSMutableDictionary alloc] initWithCapacity:drawableProperties.count + 1];
[drawableProperties enumerateKeysAndObjectsUsingBlock:^(id key, id object, BOOL *stop) {
// Copy all keys except the retained backing
if (![key isKindOfClass:[NSString class]]
|| ![(NSString *)key isEqualToString:kEAGLDrawablePropertyRetainedBacking])
[mutableDictionary setObject:object forKey:key];
}];
// Add the retained backing setting
[mutableDictionary setObject:@(YES) forKey:kEAGLDrawablePropertyRetainedBacking];
// Continue
[super setDrawableProperties:mutableDictionary];
[mutableDictionary release];
}
@end
この
@interface RetainedGLKView : GLKView
@end
@implementation RetainedGLKView
+ (Class)layerClass {
return [RetainedEAGLLayer class];
}
@end
これで、保持されたバッキングを強制したいビューに対して、GLKView の代わりに RetainedGLKView を使用できるようになりました。