由于某些原因,我的OpenGL应用程序在ios6 4英寸视网膜模拟器中运行时,获取了错误的CAEAGLLayer界限信息。
CAEAGLLayer边界打印为
layer bounds are: (0.000000,0.000000), (320.000000,480.000000)从下面的代码:
- (id)initWithCoder:(NSCoder*)coder {
if ((self = [super initWithCoder:coder])) {
// Get the layer
CAEAGLLayer *eaglLayer = (CAEAGLLayer *)self.layer;
eaglLayer.opaque = YES;
eaglLayer.drawableProperties = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:NO], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil];
printf("layer bounds are: (%f,%f), (%f,%f)\n", eaglLayer.bounds.origin.x, eaglLayer.bounds.origin.y, eaglLayer.bounds.size.width, eaglLayer.bounds.size.height );
context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];
if (!context || ![EAGLContext setCurrentContext:context]) {
[self release];
return nil;
}
animationInterval = 1.0 / 60.0;
}
return self;
}然后,窗口内容被上移,0,0不再位于正确的位置。
有人知道为什么CAEAGLLayer被设置为不正确的宽/高吗?
谢谢
发布于 2012-10-20 03:32:44
啊,其他人也有这个问题。我之前找的时候找不到。
这就是解决方案:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window.frame = CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height);
}从这里:How to make a uitableview in interface builder compatible with a 4 inch iPhone
https://stackoverflow.com/questions/12980977
复制相似问题