iphone视图翻转:viewflips从上到下而不是从右到左

时间:2010-02-28 13:52:46

标签: iphone sdk view core-animation flip

我尝试构建一个始终处于landsscape模式的应用程序。 我做了通常的事情: 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];

“窗口”似乎错过了这个事实,它处于landsscape模式。嗯。 谁能发现我的错误?

1 个答案:

答案 0 :(得分:2)

记录方法无法实现。

您需要use CATransition。 (CAT转换本身已记录在案,但翻转过渡不是。)

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