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
现在我可以使用RetainedGLKView而不是GLKView来处理那些我想强制保留后台的视图。
我没有解决方案,但请注意,视网膜模式下的新iPad中存在驱动程序错误,其中保留的支持模式完全混乱。有讨论和解决方法在这里:http://stackoverflow.com/questions/9753230/ipad-3-opengl-bug-with-keagldrawablepropertyretainedbacking-and-retina – 2012-05-06 05:21:16
你在绘制委托方法?您是否采取了明确的措施? – nielsbot 2012-07-30 21:48:46
我不记得说实话。我结束了刚刚使用CAEAGLLayer,但使用GLKit进行矩阵数学和纹理加载。 – Brett 2012-07-31 13:49:30