DNESS / cocos2d-iphone

Automatically exported from code.google.com/p/cocos2d-iphone
1 stars 0 forks source link

View incorrect size when holding it in landscape while supporting all orientations #1433

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. use a viewcontroller for rotation 
2. shouldAutorotateToInterfaceOrientation must return YES
3. hold the device in landscape orientation 
4. start up the app, 
5 the view has portrait size. 

easy to reproduce in bug914 test case. The issue is that layoutSubViews is 
called after the initialisation  of the scene. This is inconsistent, because if 
you only enable portrait or landscape layouts, layoutSubViews is called before 
the initialisation of the scene. So the system sends the notification that the 
view should rotate later then when only a subset of rotations is supported. 

iOS6 is unaffected by this and handles it correctly. 

What is the expected output? What do you see instead?
I expect the view size to be in landscape

What have I tried? 
-load the EAGLView in loadView of the viewController so layoutSubViews is 
called when the director sets the glView 
-layoutSubViews is now called before initialisation, but still thinks that the 
device is in portrait mode, so this call is useless. 

-tried to enable/disable the setRootViewController and subView lines, makes no 
difference

What cocos2d version / SVN revision are you using ?
1.1-RC0, 2.1-beta2

What iPhoneSDK are you using ?
iOS5.1, iOS4.2.1

Debug or Release ?
both

Does this happens on device ? or on the simulator ? or on both ?
Simulator for 5.1, device for 4.2.1. 

Please provide any additional information below.
I think this bug has been in cocos since using view controllers. I've tested 
1.1 beta2 and the bug was present there. 

A workaround is to reject UIInterfaceOrientationPortrait when launching. I've 
made a test case out of bug 914. 

Original issue reported on code.google.com by marcotil...@gmail.com on 10 Oct 2012 at 12:44

GoogleCodeExporter commented 9 years ago
Workaround is 
https://github.com/cocos2d/cocos2d-iphone/commit/19527d0839ebad444ace898792fb6ee
384a14fe8

Original comment by marcotil...@gmail.com on 10 Oct 2012 at 1:00

GoogleCodeExporter commented 9 years ago
Okay this is more of a iOS4 and 5 problem than cocos. For supporting both 
orientations, two view controllers are recommended, each tell the view how to 
layout for their respective orientation. 

http://developer.apple.com/library/ios/#featuredarticles/ViewControllerPGforiPho
neOS/RespondingtoDeviceOrientationChanges/RespondingtoDeviceOrientationChanges.h
tml#//apple_ref/doc/uid/TP40007457-CH7-SW1

I've updated the workaround, but this isn't a fully working example on how to 
support both orientations. 

https://github.com/cocos2d/cocos2d-iphone/commit/f4267f9eb14bc8d7fbd54230b12adda
91e5b7b56. 

Original comment by marcotil...@gmail.com on 10 Oct 2012 at 2:08