【问题标题】:change return from shouldAutorotateToInterfaceOrientation: at runTime从 shouldAutorotateToInterfaceOrientation 更改返回:在运行时
【发布时间】:2011-06-29 10:10:05
【问题描述】:

我正在使用 shouldAutorotateToInterfaceOrientation: 来响应所有方向。

在运行时,在少数情况下,我必须将返回值更改为“YES”。

但是如果我改变这个返回类型,并且我的设备没有物理转动,我的界面方向不会改变。 如何强制 uiView 检查 shouldAutorotateToInterfaceOrientation: 并在没有 UIdevice 旋转通知的情况下旋转视图。

非常感谢。

【问题讨论】:

    标签: ios uiviewcontroller


    【解决方案1】:

    从IOS 5开始的静态方法:
    [UIViewController attemptRotationToDeviceOrientation];

    【讨论】:

      【解决方案2】:

      添加这两行代码:

          [[UIDevice currentDevice] endGeneratingDeviceOrientationNotifications];
          [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
      

      【讨论】:

        猜你喜欢
        • 2012-10-19
        • 2018-08-26
        • 2013-05-10
        • 2014-05-03
        • 1970-01-01
        • 1970-01-01
        • 2013-03-27
        • 2020-03-12
        • 2016-11-09
        相关资源
        最近更新 更多