首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >iPhone 5 CAEAGLLayer返回错误的边界

iPhone 5 CAEAGLLayer返回错误的边界
EN

Stack Overflow用户
提问于 2012-10-20 03:16:52
回答 1查看 815关注 0票数 0

由于某些原因,我的OpenGL应用程序在ios6 4英寸视网膜模拟器中运行时,获取了错误的CAEAGLLayer界限信息。

CAEAGLLayer边界打印为

代码语言:javascript
复制
layer bounds are: (0.000000,0.000000), (320.000000,480.000000)

从下面的代码:

代码语言:javascript
复制
- (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被设置为不正确的宽/高吗?

谢谢

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-10-20 03:32:44

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

这就是解决方案:

代码语言:javascript
复制
- (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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/12980977

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档