isaac
isaac

Reputation: 4897

Animation Layer Orientation

Hello and thanks for looking at my question.

I have an app that supports landscape orientation only (either left or right button). It launches in landscape-left. Great - it launches in correct orientation, and it even reorients views properly (I've customized the supported orientations method) between landscape left and right.

Moving on to my question: I start the app and add a view. I start an animation and then swap my first view with a second (and a second with a third, etc).

My problem is the animation isn't consistent.

If I specify a kCATransitionFromLeft, my transition slides in from the TOP or the BOTTOM (depending on orientation of device). If I specify from kCATransitionFromRight, I get the same behavior.

If I specify kCATransitionFromBottom or kCATransitionFromTop - then the transition appears correctly with the new view sliding in from the side, however, which side it originates from still depends on the orientation of the device.

I want my view to always slide in from right to left. Obviously I could write an if/then to achieve this using kCATransitionFromBottom or kCATransitionFromTop, but my thought is that there must be an easier way.

So, is there a simple way to have animations originate consistently according to the orientation? Why does a kCATransitionFromBottom not ALWAYS originate from the bottom? How would I even begin to modify this behavior?

Thanks for any insights.

Upvotes: 0

Views: 816

Answers (1)

Adri
Adri

Reputation: 530

I'm doing the same thing on a project I'm working on, the animation is started with a swipe. The only difference is that I'm swapping UIImages.

It would help if you could post some code, the only thing I remember right now is for you to check if the parent and swapped views correctly supports landscape view:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
    if (interfaceOrientation == UIInterfaceOrientationLandscapeRight ||
        interfaceOrientation == UIInterfaceOrientationLandscapeLeft) {
        return YES;
    }
    return NO;
}

Hopes this helps!

Upvotes: 1

Related Questions