【问题标题】:Deactivate automatic screen rotation temporarily暂时停用自动屏幕旋转
【发布时间】:2013-08-05 08:27:06
【问题描述】:

对于我们的 iPad 应用程序,我希望允许在横向模式(不是纵向)下自动旋转屏幕以支持两种可能的方向。但是,在我们的应用程序的某些部分中,用户需要摇动 iPad 并将其移动到某个方向和方向,这将触发自动旋转功能,但不应该这样做。

是否可以取消和重新激活自动定向,这样在进入应用程序的此部分时方向将被锁定,而在退出时会解锁?

【问题讨论】:

    标签: ios ipad autorotate


    【解决方案1】:

    如果特定部分意味着另一个视图控制器,是的,这是可能的

    只需将这行代码添加到控制器..

    // which orientation that this view controller support
    - (NSUInteger)supportedInterfaceOrientations
    {
        return UIInterfaceOrientationMaskPortrait;
    }
    
    // prevent rotation
    - (BOOL)shouldAutorotate
    {
        return NO;
    }
    
    // after present this view controller, which orientation do you prefer ?
    - (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
    {
        return UIInterfaceOrientationPortrait;
    } 
    

    【讨论】:

    • 此答案似乎无法解决激活和停用屏幕旋转锁定的请求
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-04-05
    • 1970-01-01
    • 1970-01-01
    • 2013-12-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多