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

iOS最新版本中Better Player的屏幕旋转异常问题

Better Player iOS最新版本旋转后画面回退问题的解决方案
  • 确认项目屏幕旋转权限配置:检查Info.plist里的UISupportedInterfaceOrientations(iPhone)和UISupportedInterfaceOrientations~ipad(iPad),确保包含你需要的所有旋转方向枚举值,比如UIInterfaceOrientationPortrait、UIInterfaceOrientationLandscapeLeft、UIInterfaceOrientationLandscapeRight。
  • 核对Better Player初始化配置:初始化BetterPlayerConfiguration时,确保handleLifecycle设为true,同时将autoDetectFullscreenDeviceOrientation设置为true,这个参数负责自动识别设备旋转来同步全屏状态。
  • 手动绑定旋转事件:如果自动检测失效,在ViewController的viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator)方法中,手动调用Better Player的全屏切换方法,同步画面方向:
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
    super.viewWillTransition(to: size, with: coordinator)
    coordinator.animate(alongsideTransition: { _ in
        let isLandscape = size.width > size.height
        if isLandscape {
            self.betterPlayerViewController?.enterFullScreen()
        } else {
            self.betterPlayerViewController?.exitFullScreen()
        }
    })
}
  • 监听系统旋转通知强制刷新:添加UIDevice.orientationDidChangeNotification通知,在回调里触发播放器方向更新:
NotificationCenter.default.addObserver(self, selector: #selector(onOrientationChanged), name: UIDevice.orientationDidChangeNotification, object: nil)

@objc private func onOrientationChanged() {
    betterPlayerView.player?.updateVideoOrientation()
}
  • 升级Better Player到最新版本:该问题可能是库的版本适配bug,升级到最新版本大概率能解决。

内容的提问来源于stack exchange,提问作者Princh Kumar Verma

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.04 05:10:18