Orientation differences between iPhone 5 & 4
Orientation differences between iPhone 5 & 4
- Subject: Orientation differences between iPhone 5 & 4
- From: Rick Mann <email@hidden>
- Date: Thu, 20 Dec 2012 15:05:17 -0800
I've got a simple container view controller that holds another view controller (the Cocos 2D director), and it is the root view controller of the window. All it does is ensure that the embedded view controller's view is not resized, but just centered within its view. It does this by creating a subclass of UIView that overrides -layoutSubviews.
The embedded view is sized to 480 x 320, and everything works as expected on iPad and iPhone 5 (with the 4" default image), in the sim.
But if I run the sim in 3.5" retina hardware mode, when it comes to -layoutSubviews, the embedded view controller's view size has been changed to 320 x 480. (The content does not appear rotated, but I'm not sure what Cocos2D is doing under the hood.)
This is with the Cocos2D sample app, so things are pretty simple.
Breaking in -setFrame: in the embedded view, I can tell that it's happening AFTER my wrapper controller's -viewDidLoad, during -makeKeyAndVisible. First it changes the size, then it applies the autoresizing mask and ends up centering the view, even before my -layoutSubviews is called.
However, on a 4" screen, It skips the second call to -setFrame, and preserves the landscape sizing.
3.5" startup:
2012-12-20 15:01:03.747 Crap[14474:c07] <AppDelegate.m:64> -[AppController application:didFinishLaunchingWithOptions:]: Device is portrait
2012-12-20 15:01:03.748 Crap[14474:c07] <AppDelegate.m:66> -[AppController application:didFinishLaunchingWithOptions:]: GLView initial frame: {{0, 0}, {480, 320}}
2012-12-20 15:01:03.749 Crap[14474:c07] <AppDelegate.m:25> -[TestView setFrame:]: === Setting GL view frame to: {{0, 0}, {480, 320}}
2012-12-20 15:01:06.592 Crap[14474:c07] <Cocos2DWrapperViewController.m:99> -[Cocos2DWrapperViewController initWithDirector:]: ViewController is landscape
2012-12-20 15:01:06.622 Crap[14474:c07] <Cocos2DWrapperViewController.m:115> -[Cocos2DWrapperViewController loadView]: ViewController is landscape
2012-12-20 15:01:06.623 Crap[14474:c07] <Cocos2DWrapperViewController.m:134> -[Cocos2DWrapperViewController viewDidLoad]: ViewController is landscape
2012-12-20 15:01:06.623 Crap[14474:c07] cocos2d: animation started with frame interval: 60.00
2012-12-20 15:01:06.624 Crap[14474:c07] <AppDelegate.m:25> -[TestView setFrame:]: === Setting GL view frame to: {{0, 0}, {320, 480}}
2012-12-20 15:01:07.918 Crap[14474:c07] <AppDelegate.m:25> -[TestView setFrame:]: === Setting GL view frame to: {{80, -80}, {320, 480}}
2012-12-20 15:01:09.114 Crap[14474:c07] <Cocos2DWrapperViewController.m:40> -[CenteringWrapperView layoutSubviews]: Device is portrait
2012-12-20 15:01:09.114 Crap[14474:c07] <Cocos2DWrapperViewController.m:53> -[CenteringWrapperView layoutSubviews]: Green view bounds: {{0, 0}, {480, 320}}
2012-12-20 15:01:09.114 Crap[14474:c07] <Cocos2DWrapperViewController.m:62> -[CenteringWrapperView layoutSubviews]: GL view frame: {{80, -80}, {320, 480}}
2012-12-20 15:01:09.115 Crap[14474:c07] <AppDelegate.m:25> -[TestView setFrame:]: === Setting GL view frame to: {{80, -80}, {320, 480}}
2012-12-20 15:01:10.450 Crap[14474:c07] cocos2d: surface size: 640x960
4" startup:
2012-12-20 14:58:54.252 Crap[14432:c07] <AppDelegate.m:64> -[AppController application:didFinishLaunchingWithOptions:]: Device is portrait
2012-12-20 14:58:54.254 Crap[14432:c07] <AppDelegate.m:66> -[AppController application:didFinishLaunchingWithOptions:]: GLView initial frame: {{0, 0}, {480, 320}}
2012-12-20 14:58:54.254 Crap[14432:c07] <AppDelegate.m:25> -[TestView setFrame:]: === Setting GL view frame to: {{0, 0}, {480, 320}}
2012-12-20 14:59:34.628 Crap[14432:c07] <Cocos2DWrapperViewController.m:99> -[Cocos2DWrapperViewController initWithDirector:]: ViewController is landscape
2012-12-20 14:59:34.629 Crap[14432:c07] <Cocos2DWrapperViewController.m:115> -[Cocos2DWrapperViewController loadView]: ViewController is landscape
2012-12-20 14:59:34.630 Crap[14432:c07] <Cocos2DWrapperViewController.m:134> -[Cocos2DWrapperViewController viewDidLoad]: ViewController is landscape
2012-12-20 14:59:34.630 Crap[14432:c07] cocos2d: animation started with frame interval: 60.00
2012-12-20 14:59:34.631 Crap[14432:c07] <AppDelegate.m:25> -[TestView setFrame:]: === Setting GL view frame to: {{44, 0}, {480, 320}}
2012-12-20 14:59:45.253 Crap[14432:c07] <Cocos2DWrapperViewController.m:40> -[CenteringWrapperView layoutSubviews]: Device is portrait
2012-12-20 14:59:45.254 Crap[14432:c07] <Cocos2DWrapperViewController.m:53> -[CenteringWrapperView layoutSubviews]: Green view bounds: {{0, 0}, {568, 320}}
2012-12-20 14:59:45.254 Crap[14432:c07] <Cocos2DWrapperViewController.m:62> -[CenteringWrapperView layoutSubviews]: GL view frame: {{44, 0}, {480, 320}}
2012-12-20 14:59:45.255 Crap[14432:c07] <AppDelegate.m:25> -[TestView setFrame:]: === Setting GL view frame to: {{44, 0}, {480, 320}}
2012-12-20 15:00:00.932 Crap[14432:c07] cocos2d: surface size: 960x640
Help! Thanks!
--
Rick
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden