Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting a rotation transformation to a UIView or its layer doesn't seem to work?

I'm trying to have one of the children views in my screen (owned by one view controller) not rotate when the device rotates. My view controller allows rotations as it should, and I'm trying to apply a 90-degree rotation to the one "stationary" view to counteract the overall rotation.

Problem is, everything seems to rotate anyways, and the transform doesn't seem to do anything. I've attempted with an affine transform on the view, and with a 3d transform on the layer (below). The method is getting called, but I never see a visual difference.

Any thoughts? Thanks.

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation duration:(NSTimeInterval)duration
{
    CALayer *layer = stuckview.layer;
    layer.transform = CATransform3DMakeRotation(90, 0, 0, 1);
}    
like image 875
Ben Zotto Avatar asked Jul 02 '10 21:07

Ben Zotto


1 Answers

Is your code actually executed? (Do you implement shouldAutorotateToInterfaceOrientation: ?)

stuckview.transform = CGAffineTransformMakeRotation(M_PI_2); 

should do the job.

Note: The functions take radians not degrees.

like image 163
Eiko Avatar answered Oct 12 '22 22:10

Eiko