flip transition flips view from top in landscape mode

百般思念 提交于 2019-12-05 23:01:03

The animation constants have been defined with portrait mode in mind. If you define your application to be landscape mode only, you have to think about these animation constants with your head tilted 90 degrees.

Let's say your device's top is titled to the left, than you would set the animation with

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.navigationController.view cache:YES];

and it would curl from the right. That's because the bottom of the device faces to the right in this case.

The bad thing is that UIViewAnimationTransitionFlipFromBottom is not defined. I guess you could rotate the coordinate system of the animation with 90 degrees, but I can't help you with that.

I don't know what Apple was thinking when they developed this API. Here's the workaround I used:

// Assume this code is in a view controller subclass
- (UIViewAnimationOptions)viewAnimationOptionTransitionFlipFromRight
{
    switch (self.interfaceOrientation) {

        case UIInterfaceOrientationPortrait:
            return UIViewAnimationOptionTransitionFlipFromRight;

        case UIInterfaceOrientationLandscapeLeft:
            return UIViewAnimationOptionTransitionFlipFromBottom;

        case UIInterfaceOrientationLandscapeRight:
            return UIViewAnimationOptionTransitionFlipFromTop;

        case UIInterfaceOrientationPortraitUpsideDown:
            return UIViewAnimationOptionTransitionFlipFromLeft;
    }
}

You can adjust the code accordingly if you want to flip in a different direction. If you want to use the page curl transitions, however, I'm afraid you may be completely out of luck.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!