0

出于某种原因,我的 OpenGL 应用程序在 ios6 4 英寸 Retina 模拟器中运行时获得了错误的 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 设置为不正确的宽度/高度?

谢谢

4

1 回答 1

0

啊,其他人也有这个问题。之前找的时候没找到。

这是解决方案:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

    self.window.frame = CGRectMake(0, 0, [[UIScreen mainScreen]bounds].size.width, [[UIScreen mainScreen]bounds].size.height);

}

从这里开始:如何在界面生成器中制作与 4 英寸 iPhone 兼容的 uitableview

于 2012-10-19T19:32:44.207 回答