I am fairly new to iPhone, but have minor experience in Objective-C.
I have started learning iPhone Cocoa Touch frameworks, reading one of the book, where I have found a program sample for auto-rotation. In this program there are 2 views created - portrait and landscape. Each view has 2 buttons. As a task the handset once repositioned it changes its view (when it is in vertical position the view is set to portrait but when it changes to horizontal the view is replaced with landscape layout). My question is - in the below code there is CGRectMake - what is it for? Why the view needs to be redrawn if it is already replaced and rotated? When I disable last line, the program works completely fine. There is no difference when it is enabled or disabled. By the way I use iPhone Simulator 4.0.
Thanks for any reply
I have started learning iPhone Cocoa Touch frameworks, reading one of the book, where I have found a program sample for auto-rotation. In this program there are 2 views created - portrait and landscape. Each view has 2 buttons. As a task the handset once repositioned it changes its view (when it is in vertical position the view is set to portrait but when it changes to horizontal the view is replaced with landscape layout). My question is - in the below code there is CGRectMake - what is it for? Why the view needs to be redrawn if it is already replaced and rotated? When I disable last line, the program works completely fine. There is no difference when it is enabled or disabled. By the way I use iPhone Simulator 4.0.
Code:
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
self.view = self.landscape;
self.view.transform = CGAffineTransformIdentity;
self.view.transform = CGAffineTransformMakeRotation(degreesToRadian(0));
self.view.bounds = CGRectMake(0.0, 0.0, 300.0, 480.0);
}
Thanks for any reply