gpt4 book ai didi

iphone - 有没有办法从 shouldAutorotateToInterfaceOrientation 跳过旋转动画?

转载 作者:行者123 更新时间:2023-12-03 19:20:25 26 4
gpt4 key购买 nike

我想允许方向根据对 View Controller 的 shouldAutorotateToInterfaceOrientation 调用进行旋转。但是,我希望它立即执行此操作并跳过旋转动画(导致整个 View 旋转时角落显示黑色旋转动画的动画。

有谁知道是否有办法指定您希望它立即发生(没有动画)?

最佳答案

为了执行您想要的操作,您必须手动旋转(并调整大小) View 。没有任何属性可以让您轻松更改以轻松执行您想要的操作。下面是注册设备旋转事件的代码。

 - (void)viewDidLoad {
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(orientationChanged:)
name:UIDeviceOrientationDidChangeNotification object:nil];
//Whenever the device orientation changes, orientationChanged will be called

}


- (void)orientationChanged:(NSNotification *)notification
{
UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
//Based upon which orientation the device is in, update your View rotations.
//A simple view.transform = CGAffineTransformMakeRotation(whatever); will work well.
}

我认为您应该完全删除 shouldAutoRotateToInterfaceOrientation: 函数。当 View 卸载时,您还应该调用 [[UIDevice currentDevice] endGenerateDeviceOrientationNotifications];

关于iphone - 有没有办法从 shouldAutorotateToInterfaceOrientation 跳过旋转动画?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3233032/

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