1

我尝试构建一个一直处于横向模式的应用程序。我做了通常的事情:plist 添加了 UIInterfaceOrientation / UIInterfaceOrientationLandscapeRight 在界面生成器中旋转了 XIB,并在视图顶部使用了小箭头。

my code for launching:
- (void)applicationDidFinishLaunching:(UIApplication *)application {    
        [[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
    FlipViewController *flip = [[FlipViewController alloc] initWithNibName:@"FlipViewController" bundle:nil];
    [window addSubview:flip.view];
    [window makeKeyAndVisible];
}

但是当我尝试执行“UIViewAnimationTransitionFlipFromLeft”时,页面会从上到下而不是从右到左翻转。:-/

这是我用来翻转视图的代码:

[UIView beginAnimations:@"View Flip" context:nil];
    [UIView setAnimationDuration:1.25];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];

    UIViewController *coming = nil;
    UIViewController *going = nil;
    UIViewAnimationTransition transition;

    if (self.blueViewController.view.superview == nil) 
    {   
        coming = blueViewController;
        going = yellowViewController;
        transition = UIViewAnimationTransitionFlipFromLeft;
    }
    else
    {
        coming = yellowViewController;
        going = blueViewController;
        transition = UIViewAnimationTransitionFlipFromRight;
    }

    [UIView setAnimationTransition: transition forView:self.view cache:YES];
    [coming viewWillAppear:YES];
    [going viewWillDisappear:YES];
    [going.view removeFromSuperview];
    [self.view insertSubview: coming.view atIndex:0];
    [going viewDidDisappear:YES];
    [coming viewDidAppear:YES];

    [UIView commitAnimations];

“窗口”似乎忽略了一个事实,即它处于横向模式。嗯。谁能发现我的错误?

4

1 回答 1

2

使用记录的方法是不可能的。

您需要使用 CATransition。(CATransition 本身已记录在案,但翻转过渡没有。)

要使用翻转过渡,请将过渡设置type为“oglFlip”并设置subtype为 fromLeft/Top/Right/Bottom。

于 2010-02-28T14:24:37.900 回答