出于某种原因,在ios6 4英寸Retina模拟器中运行时,我的OpenGL应用程序获取了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被设置为不正确的宽度/高度?
由于
答案 0 :(得分:0)
这是解决方案:
- (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