Can someone give me a detailed explanation of why iOS handles landscape orientation the way it does with respect to frame and transformation?
What I'm talking about is the following behavior, displayed by registering the description of the views in various Lifecycle view methods:
viewDidLoad: "UIView: 0x1edb5ba0; frame = (0 0; 568 320); autoresize = W+H; layer = <CALayer: 0x1edb5c50>" viewWillAppear: "UIView: 0x1edb5ba0; frame = (0 0; 320 568); autoresize = W+H; layer = <CALayer: 0x1edb5c50>" viewDidAppear: "UIView: 0x1edb5ba0; frame = (0 0; 320 568); transform = [0, 1, -1, 0, 0, 0]; autoresize = W+H; layer = <CALayer: 0x1edb5c50>"
The consequences are subtle, but very intriguing.
For example, I launch my application with the Orientation of the Orientation Interface and the Orientation of the Supported Interface configured as "Landscape (right button of the house)"
Then I show my rootViewController as follows:
self.viewController = [[MyViewController alloc] initWithNibName:nil bundle:nil]; self.window.rootViewController = self.viewController;
This .xib has the orientation set to "Landscape" and the frame is set to 0, 0, 568, 320. It displays correctly and I can touch all the points on the screen.
The problem arises when I present subview as follows:
SomeView *someView = [[SomeView alloc] initWithFrame:self.view.frame]; [self.view addSubview:someView];
At this point in time, self.view.frame is reported as (0 0; 320 568), and self.view.transform is reported as transform = [0, 1, -1, 0, 0, 0]. The best random scenario, the end result is that I can only touch the left 320px view that I just displayed, in the worst case, that the layout of the view is locked.
Thanks to various SO questions, I found out that the right way to do this is as follows:
SomeView *someView = [[SomeView alloc] initWithFrame:self.view.bounds]; [self.view addSubview:someView]
That I did not find out why, and it is very interesting to me.
What I'm even more curious about is why the view is processed as it is at the time of instantiation and display.
It has been quite a while since I got confused with the landscape application, but for some reason I think the current implementation of this is different from earlier versions of iOS, is that right?