From 75a319d7fb3b3bd730ab518a84608532fe1b1e7e Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 2 Jul 2026 21:54:21 +0800 Subject: [PATCH] fix(iOS): fix presentActivitySheet keyWindow deprecation, use windowScene.keyWindow + fallback --- Sources/HLSRecorder.swift | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Sources/HLSRecorder.swift b/Sources/HLSRecorder.swift index bb8e2aa..53741ab 100644 --- a/Sources/HLSRecorder.swift +++ b/Sources/HLSRecorder.swift @@ -354,11 +354,16 @@ final class HLSRecorder: ObservableObject { return } - // 找最顶层可见的 VC(遍历所有 window) + // 找最顶层可见的 VC:先用 keyWindow,再 fallback 到任意 window var topVC: UIViewController? - for window in windowScene.windows where window.isKeyWindow { - topVC = window.rootViewController - break + if let keyWindow = windowScene.keyWindow { + topVC = keyWindow.rootViewController + } + if topVC == nil { + for window in windowScene.windows where !window.isHidden && window.bounds.size != .zero { + topVC = window.rootViewController + if topVC != nil { break } + } } if topVC == nil { topVC = windowScene.windows.first?.rootViewController