views:

93

answers:

2

Hi all,

I don't understand what's wrong in my very simple application with device rotation :

  • I built my view with interface builder. (See screen capture here)
  • I specified <key>UIInterfaceOrientation</key><string>UIInterfaceOrientationLandscapeRight</string> in my info.plist file.
  • I had a (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {return YES;} in my root view controller.

The area on the left (shown in red on the capture), around 20 pixel width, keeps inactive (nothing append if I hit a button in this area). In fact the full screen is active only in portrait mode, in landscape right mode there is this 20 pixels width inactive area, in landscape left mode this inactive area is on the right, in portrait upside down mode this area is on the bottom.

I read lots of posts and documentation about UIView rotation, but I did not find anything to solve this problem (I tried to play with view.frame and view.bounds without any success).

Anybody has an idea ?

Thanks a lot.

Regards. Sébastien.

A: 

One of your views is probably not autoresized correctly.

After rotation, it still has its old bounds of, for example, 320 x 460. Since views normally don't clip their contained views you don't see a difference.

Events on the other hand are only delivered to views that are contained in their superviews bounds.

Nikolai Ruhe
A: 

Ok, so I had a few NSLog lines to best understand what's happen.

First, display window frame and bounds sizes (Portrait mode first):

in appdelegate didFinishLaunchingWithOptions
Windows frame : 0.000000, 0.000000, 320.000000, 480.000000
Windows bounds : 0.000000, 0.000000, 320.000000, 480.000000

in root view viewDidLoad
View frame : 0.000000, 20.000000, 320.000000, 460.000000
View bounds : 0.000000, 0.000000, 320.000000, 460.000000

All is correct.

Then rotate to landscape right.
In root view willRotateToInterfaceOrientation :

Window frame : 0.000000, 0.000000, 320.000000, 480.000000
Window bounds : 0.000000, 0.000000, 320.000000, 480.000000

View frame : 0.000000, 20.000000, 320.000000, 460.000000
View bounds : 0.000000, 0.000000, 320.000000, 460.000000

Same thing, all is correct.
Now in root view didRotateFromInterfaceOrientation

Window frame : 0.000000, 0.000000, 320.000000, 480.000000
Window bounds : 0.000000, 0.000000, 320.000000, 480.000000

View frame : 0.000000, 0.000000, 300.000000, 480.000000
View bounds : 0.000000, 0.000000, 480.000000, 300.000000

Window frame and bounds are wrong, it should be 0.000000, 0.000000, 480.000000, 320.000000 no ?

View bounds are correct, but frame should be 0.000000, 20.000000, 480.000000, 300.000000 no ?

Are my expectations about position and size wrong ?

Regards.
Sébastien.

Sébastien
Please edit your question instead of posting answers. All your findings are correct. The window is **not** turned, its contents are.
Nikolai Ruhe
Thanks Nikolai, I'm going to search this way.
Sébastien