iPhone视图翻转:视图从上到下翻转,而不是从右到左

发布于 2024-08-22 21:25:57 字数 1668 浏览 10 评论 0原文

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

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

i try to build a app that is in landsscape mode all the time.
I did the usual stuff:
plist added UIInterfaceOrientation / UIInterfaceOrientationLandscapeRight
rotated the XIBs in interface builder with the little arrow in top of view.

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];
}

But when i try to do a "UIViewAnimationTransitionFlipFromLeft" the page flips from top to bottom instead of right to left. :-/

This is the code i use to flip the views:

[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" seems to have missed the fact, that it is in landsscape-mode. Hmmm.
can anyone spot my mistake?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

旧话新听 2024-08-29 21:25:57

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

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

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

Not possible with documented methods.

You need to use CATransition. (CATransition itself is documented, but the flip transition is not.)

To use the flip transition, set the transition's type to "oglFlip" and set subtype to fromLeft/Top/Right/Bottom.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文