views:

34

answers:

0

I'm trying to apply '3D perspective' to a UIView with a UIScrollView embedded inside. This will allow the user to scroll through a set of photos with a 3D effect.

Trouble is, the code below works fine in portrait orientation... but when I rotate the view to the landscape orientation, the scrolling no longer works.

I have tried to nest the scrollview inside another UIView and setting autoRotation to NO, but it still doesn't work work as desired.

Any ideas?

CALayer *layer = scrollView.layer;
CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity;
rotationAndPerspectiveTransform.m34 = 1.0 / -800;
rotationAndPerspectiveTransform = CATransform3DRotate(rotationAndPerspectiveTransform, 45.0f * M_PI / 180.0f, 0.0f, 1.0f, 0.0f);
layer.transform = rotationAndPerspectiveTransform;