gpt4 book ai didi

ios - 暂时停用自动屏幕旋转

转载 作者:可可西里 更新时间:2023-11-01 06:10:20 24 4
gpt4 key购买 nike

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

是否可以取消并重新激活自动定位,以便在进入应用程序的这一部分时锁定方向并在退出时解锁?

最佳答案

如果特定部分意味着另一个 View Controller ,是的,这是可能的

只需将这行代码添加到 Controller 中..

// 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;
}

关于ios - 暂时停用自动屏幕旋转,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18053656/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com