【问题标题】:iphone view flipping: viewflips from top to bottom instead of right to leftiphone视图翻转:从上到下而不是从右到左的视图翻转
【发布时间】:2010-02-28 13:52:46
【问题描述】:

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

"window" 似乎忽略了它处于横向模式的事实。嗯。 谁能发现我的错误?

【问题讨论】:

    标签: iphone sdk view core-animation flip


    【解决方案1】:

    不可能使用记录的方法。

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

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

    【讨论】:

    • UPS。比我想象的要复杂得多。使用未记录的“oglFlip”很可能会阻止我将我的应用程序放入 apstore?
    猜你喜欢
    • 2014-12-31
    • 2014-05-30
    • 2010-10-25
    • 2011-04-02
    • 1970-01-01
    • 1970-01-01
    • 2019-05-27
    • 1970-01-01
    • 2018-01-27
    相关资源
    最近更新 更多