iOS旋转设备没有旋转动画

发布于 2024-12-05 09:27:43 字数 522 浏览 0 评论 0原文

实现类似于 iPhone 的标准 iPod 应用程序中的效果的正确方法是什么 - 当设备旋转到横向模式时,视图更改为覆盖流,但过渡类型是淡入淡出而不是旋转屏幕?

这就是我加载模态视图的方式:

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
        carouselView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentModalViewController:carouselView animated:YES];
    }
}

谢谢!

安德鲁斯

What would be the correct way to achieve an effect similar to the one in the standard iPod app of the iPhone - when the device is rotated to landscape mode, the view changes to cover flow, but the type of transition is fade and not the rotating screen?

This is how I am loading the modal view:

- (void) willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (UIInterfaceOrientationIsLandscape(toInterfaceOrientation)) {
        carouselView.modalTransitionStyle = UIModalTransitionStyleCrossDissolve;
        [self presentModalViewController:carouselView animated:YES];
    }
}

Thanks!

Andrius

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

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

发布评论

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

评论(1

爱,才寂寞 2024-12-12 09:27:43

我后来发现使用这个解决方案更稳定:

在父视图控制器(在我的例子中是选项卡视图控制器)viewdidload方法中添加这个:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];

然后添加这个方法:

- (void) didRotate:(NSNotification *)notification {     

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (UIInterfaceOrientationIsLandscape(orientation) && !self.modalViewController) {
        [self presentModalViewController:carouselView animated:YES];
        [Globals sharedGlobals].startedAtLandscape = YES;
    }

    if (UIInterfaceOrientationIsPortrait(orientation) && self.modalViewController) {
        [self dismissModalViewControllerAnimated:YES];    
        [Globals sharedGlobals].startedAtLandscape = NO;
    }
}

最后如果你想阻止旋转动画,像这样修改这个方法:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
        return NO;
    }
    return YES;
}

I later found that it is more stable to use this solution:

In the parent view controller (in my case it is tab view controller) viewdidload method add this:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:@"UIDeviceOrientationDidChangeNotification" object:nil];

and then add this method:

- (void) didRotate:(NSNotification *)notification {     

    UIDeviceOrientation orientation = [[UIDevice currentDevice] orientation];
    if (UIInterfaceOrientationIsLandscape(orientation) && !self.modalViewController) {
        [self presentModalViewController:carouselView animated:YES];
        [Globals sharedGlobals].startedAtLandscape = YES;
    }

    if (UIInterfaceOrientationIsPortrait(orientation) && self.modalViewController) {
        [self dismissModalViewControllerAnimated:YES];    
        [Globals sharedGlobals].startedAtLandscape = NO;
    }
}

And finally if you want to prevent the rotation animation, modify this method like this:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if(UIInterfaceOrientationIsLandscape(interfaceOrientation)) {
        return NO;
    }
    return YES;
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文