gpt4 book ai didi

iphone - iOS旋转设备无旋转动画

转载 作者:行者123 更新时间:2023-11-28 23:13:13 25 4
gpt4 key购买 nike

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

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

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

谢谢!

安德鲁斯

最佳答案

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

在父 View Controller (在我的例子中是选项卡 View Controller )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;
}

关于iphone - iOS旋转设备无旋转动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7457541/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com