2012-10-19 33 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