检测iOS中的旋转更改 [英] Detect rotation changes in iOS
问题描述
我正在制作一款需要在旋转时进行一点界面重新排列的iOS应用。我试图通过实现 - (void)orientationChanged:(NSNotification *)note
来检测这一点,但这会给我通知设备面朝上或面朝下的时间。
I am making an iOS app that needs to do a little interface rearrangement upon rotation. I am trying to detect this by implementing - (void)orientationChanged:(NSNotification *)note
, but this gives me notifications for when the device is face up or face down.
我希望在界面改变方向时获得通知。
I want a way to just get notified when the interface changes orientations.
推荐答案
自iOS 8以来,上述方法已被弃用,处理和检测设备轮换的正确方法是:
Since iOS 8, above methods were deprecated, and the proper way to handle and detect device rotation is:
-(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id )协调员;
要检测设备方向,您应该(根据文档):调用 statusBarOrientation 方法确定设备方向
To detect device orientation, you should (according to documentation): call the statusBarOrientation method to determine the device orientation
这篇关于检测iOS中的旋转更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!