You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

iOS16下ViewController Dismiss后方向异常及相关错误日志求助

iOS 16 连续 Dismiss 视图控制器后旋转异常问题

已使用supportedInterfaceOrientations和setNeedsUpdateOfSupportedInterfaceOrientation替代废弃的shouldAutorotate和attemptRotationToDeviceOrientation,移除所有废弃API后,测试连续dismiss两个视图控制器的逻辑时出现异常。

视图控制器代码

// MainViewController present FirstViewController.
final class MainViewController {
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        .allButUpSideDown
    }
}

// FirstViewController 仅支持竖屏,且 present SecondViewController
final class FirstViewController {
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        .portrait
    }
}

// 视图层级最上层的控制器
final class SecondViewController {
    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        .allButUpSideDown
    }
}

视图层级结构

MainViewController(allButUpSideDown)
-- FirstViewController(portrait)
----SecondViewController(allButUpSideDown)

触发问题的 Dismiss 方法

func dismissAllViewControllers() {
    firstViewController.dismiss(animated: false) {
        firstViewController.dismiss(animated: true)
    }
}

问题现象

调用上述方法后,返回MainViewController界面出现状态栏异常、无法自动旋转的问题,同时系统抛出如下错误日志:

A new orientation transaction token is being requested while a valid one already exists. reason=Fullscreen transition (dismissing): fromVC=<HyunjinTutorialProject.PortraitViewController: 0x109606d60>; toVC=<HyunjinTutorialProject.MainNavigationViewController: 0x10801fe00>;;; windowOrientation=portrait; sceneOrientation=landscapeRight; existingTransaction=<_UIForcedOrientationTransactionToken: 0x282fd2ee0; state: committing; originalOrientation: landscapeRight (3)>

疑问

这是iOS 16的UI问题吗?是否有其他人遇到过相同的错误日志?

内容的提问来源于stack exchange,提问作者HyunJin Yoon

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.16 15:35:20