我有一个非常棘手的代码,因为有时我会设置一个新的方向。
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
是否可以在 statusBarOrientation 更改时添加观察者或通知?我想知道当前的方向是什么。
我有一个非常棘手的代码,因为有时我会设置一个新的方向。
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
是否可以在 statusBarOrientation 更改时添加观察者或通知?我想知道当前的方向是什么。
您使用的代码非常棘手。
您正在使用的属性声明如下:
@property (nonatomic, readonly) UIDeviceOrientation orientation
因此,使用此私有方法时,您的应用程序将被拒绝。
如果要更改界面方向,则应查看UIViewController
回调。
关于您的问题,您可以手动完成。设置新方向后发送自定义通知。然后随心所欲地捕捉该通知。但请注意我之前所说的。
有关更多信息,您可以在method-uidevice-setorientation-is-it-still-denied上查看此 stackoverflow 主题。
希望能帮助到你。