Landscape-only orientation + view controllers: What am I still missing?
- by mahboudz
Hi. I can't believe I am still having problems with screen orientation, now on the iPad. This is an app that only supports one of the two landscape orientation.
In my info.plist, I include:
<string>UIInterfaceOrientationLandscapeRight</string>
<string>UIInterfaceOrientationLandscapeLeft</string>
In Interface Builder, all my views are created in landscape orientation. Only the main Window is not, but I don't see a way to change that. When launched, I get the following coordinates for my main window and the main viewcontroller view:
Window frame {{0, 0}, {768, 1024}} mainView frame {{0, 0}, {748, 1024}}
(Changing the frame at runtime to be what I expect, does not change the odd behavior.)
All other views after that show these coordinates when summoned (when loaded but before being presented):
frame of keysig {{0, 0}, {1024, 768}}
frame of instrumentSelect {{20, 0}, {1024, 768}}
frame of settings {{0, 0}, {467, 300}}
In all my viewControllers, i respond to shouldAutorotateToInterfaceOrientation with:
return ((interfaceOrientation == UIInterfaceOrientationLandscapeLeft) ||
(interfaceOrientation == UIInterfaceOrientationLandscapeRight));
In my app, everything (almost) functions as expected. The app launches into one of the two landscape modes. The views (and viewcontrollers) display everything where it belongs, taps work all across the screen, as expected. However, there are two clues that something is still wrong.
Clue #1: I have two viewcontrollers that are UITabeViewControllers. When summoned, they are supposed to open up their views and scroll to the selected row of the table. However it is evident that they scroll, but they don't scroll down far enough. It seems that they think that the screen extends further down and they scroll just enough to move the row to a place near the bottom of the screen, but that location is not visible.
When the views are loaded, the coordinates are:
frame of keysig {{0, 0}, {1024, 768}}
frame of instrumentSelect {{20, 0}, {1024, 768}}
When I present them using a popover, the frames get resized to:
frame of keysig {{0, 0}, {320, 655}}
frame of instrumentSelect {{0, 0}, {320, 655}}
The frame of the viewController that does the presentation, same mainView frame mentioned above is:
frame of self {{20, 0}, {748, 1024}}
I have also tried to accomplish the same thing with presentModalViewController instead of presentPopover, and have the same results.
This is what the popovers look like:
In both cases, the selected row is below the horizon, even though the tableView did visibly scroll in order to make the row visible.
I am not sure what to try next. I checked each UITable's scrollView content coordinates and they seemed reasonable. It almost seems like a UITable internal rect gets created with the wrong number and stays that way.
Clue #2: All my actionsheets come up with a width of 320. I can only assume that the iPad allows actionSheets in only 320 or 480 widths and since it somehow thinks that the screen is oriented in portrait mode, and then uses the narrower width.
There you have it. I can't believe I am still getting hung up on orientation issues. I swear Apple doesn't make it easy to have a landscape app. Any ideas?