gpt4 book ai didi

ios - 在 Swift 的旋转过程中是否有类似 didRotateFromInterfaceOrientation 的方法?

转载 作者:搜寻专家 更新时间:2023-10-31 08:11:55 24 4
gpt4 key购买 nike

当我旋转设备时,我正在尝试对 UIActivityIndi​​cator 进行 .StartAnimating,我正在尝试使用覆盖功能:didRotateFromInterfaceOrientation;然而,这个函数在旋转发生后被调用,我想在实际旋转期间制作动画。

我正在寻找一种在旋转时调用的方法。我查阅了文献,发现只有贬值的功能可能有用。

目前有什么方法可以用于此目的吗?

最佳答案

只需使用此代码段来检查方向更改

Swift 1.x/2.x

override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
if UIDevice.currentDevice().orientation.isLandscape.boolValue {
print("Landscape")
} else {
print("Portrait")
}
}

swift 3.x

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
if UIDevice.current.orientation.isLandscape {
print("Landscape")
} else {
print("Portrait")
}
}

关于ios - 在 Swift 的旋转过程中是否有类似 didRotateFromInterfaceOrientation 的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34467610/

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