Hello!
I'm trying to create an iPad application but am encountering a questionable behavior from the simulator (Can't be tested on a device for now..).
The issue is when having any UIView rotate through its transform property, and then allowing the view containing it to be manipulated by changing the orientation of the iPad. This can be simplified by creating a new View-based iPad project and inserting the following code to the view controller:
- (IBAction) rotate:(UIView*)sender {
if (CGAffineTransformIsIdentity(sender.transform)) {
sender.transform = CGAffineTransformMakeRotation(M_PI / 4);
} else {
sender.transform = CGAffineTransformIdentity;
}
}
Then adding a single button to the view and linking its action with the above method.
As you see, the method should rotate the button when clicked, and then un-rotate when clicked again - and it does just that. However, when the button is rotated, and you change the orientation (from the Hardware menu), it'll start acting really weird - changing its shape or disappearing altogether.
Worth noting that if I create a translation transform, this does not happen.
My question is:
1. Since I don't have an iPad at the moment (working on that), can anyone tell me if that happens on the device as well?
2. Am I doing something wrong here? Maybe this is not the way to rotate the UIView? If so, what is?
Update: From the documentation, it seems that If [the transform] property is not the identity transform, the value of the frame property is undefined and therefore should be ignored. So the problem is probably the fact that I am using the autoresizeMask while changing the transform property. So how can or should this be done?
Thanks, Aviad.