我发现视图的“缩放”方法显然需要设置为正确调整视图大小(因为视图是基于位置的而不是像素,并且由于某些奇怪的原因,位置不会随着分辨率的提高等而调整)。这是我唯一能真正找到的东西。我注意到在 GLView 的 init 方法中包含以下调用检查和设置...但我仍然想知道是否有更好的方法。我不是必须通过将高度和宽度乘以 scale 属性来手动调整所有内容的大小吗?
- (id)initWithFrame:(CGRect)frame
{
NSLog(@"frame: Origin: x:%f y:%f, Size: width:%f height:%f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height);
self = [super initWithFrame:frame];
if (self) {
**if([[UIScreen mainScreen] respondsToSelector: NSSelectorFromString(@"scale")])
{
if([self respondsToSelector: NSSelectorFromString(@"contentScaleFactor")])
{
[self setContentScaleFactor:[[UIScreen mainScreen] scale]];
NSLog(@"Scale factor: %f", [[UIScreen mainScreen] scale]);
}
}**
NSLog(@"frame: Origin: x:%f y:%f, Size: width:%f height:%f Scale factor: %f", frame.origin.x, frame.origin.y, frame.size.width, frame.size.height, self.contentScaleFactor);
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)super.layer;
eaglLayer.opaque = YES; // set to indicate that you do not need Quartz to handle transparency. This is a performance benefit.
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
if (!context || ![EAGLContext setCurrentContext:context]) {
return nil;
}