0

我有一个支持所有方向的应用程序,但是单击某个按钮时,我想让该应用程序仅支持当前方向。怎么做?

4

1 回答 1

0

设备方向实际上是整数。您可以做的是有一个局部变量,当单击按钮时将其设置为当前方向,然后从方向方法仅返回该方向。如果未设置该整数,则返回设备的方向。另请注意,iOS 6.0 中已弃用 shouldAutorotateToInterfaceOrientation。从文档:

shouldAutorotateToInterfaceOrientation : (Deprecated in iOS 6.0. Override the supportedInterfaceOrientations and preferredInterfaceOrientationForPresentation methods instead.)

编辑:这是 UIInterfaceOrientation 的参考。

typedef枚举:NSInteger { UIInterfaceOrientationPortrait = UIDeviceOrientationPortrait,UIInterfaceOrientationPortraitUpsideDown = UIDeviceOrientationPortraitUpsideDown,UIInterfaceOrientationLandscapeLeft = UIDeviceOrientationLandscapeRight,UIInterfaceOrientationLandscapeRight = UIDeviceOrientationLandscapeLeft } UIInterfaceOrientation;

于 2013-10-24T19:22:25.953 回答