Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to auto-rotate a modal view but not its parent?

It seems that if a modal view's parent returns false to shouldAutoRotate... the modal view will also not autorotate. How can I have a main view which will never rotate, and a modal view which will always rotate?

like image 942
morgancodes Avatar asked Nov 05 '22 14:11

morgancodes


1 Answers

You may try to observe for orientation events (UIDeviceOrientationDidChangeNotification) in your modal view controller and then add a transformation to your view layer using the CATransform3DMakeRotation to get an appropriate rotation around Z or basically with

[myLayer setValue:[NSNumber numberWithInt:M_PI*0.5f] forKeyPath:@"transform.rotation.z"]; // or - M_PI*0.5f depending orientation: left or right

You can also use an animation to get an animated rotation. Is it what you're asking for?

For observing orientation events read this chapter : Getting the Current Device Orientation

For Layer transform read this chapter : Layer Geometry and Transforms

Regards.

V.Zgueb

like image 190
Vincent Zgueb Avatar answered Nov 12 '22 16:11

Vincent Zgueb