2012-10-19 31 views
0

出于某种原因,我的OpenGL应用程序在ios6 4英寸Retina模拟器中运行时,获取了CAEAGLLayer的错误边界信息。iPhone 5 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

啊,别人有这个问题为好。我之前搜索时找不到它。

这是解决方案:

- (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