Hi!
I want to implement my own way of autorotating the interface: Code:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
NSLog(@"should!");
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.4];
if (interfaceOrientation == UIInterfaceOrientationLandscapeRight) {
trash.transform = CGAffineTransformMakeRotation(M_PI*0.5);
}
else if (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
trash.transform = CGAffineTransformMakeRotation(-M_PI*0.5);
}
else if (interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
trash.transform = CGAffineTransformIdentity;//CGAffineTransformMakeRotation(M_PI);
}
else {
trash.transform = CGAffineTransformIdentity;
}
[UIView commitAnimations];
return NO;
}
As you see I've a UIView (in fact UIImageView) - trash and I'm rotating it using CGAffineTransformMakeRotation when interface orientation is changed. It works great except, the method never gets called when the interface orientation is default portrait (up side down works). So the trash is rotated to the previous orientation instead of default. I'm worried a little bit about the comment above the method (automatically added when creating UIViewController), that says "to allow orientations other than the default portrait orientation".
When I return the YES instead of NO of course the method is called for every orientation, but I don't want to animate the whole interface, but only some elements.
Plz help.