fix: iOS synchronize set safeAreaInset#1007
Open
RoeKun wants to merge 3 commits intoTencent-TDS:mainfrom
Open
Conversation
7d04072 to
631f5c9
Compare
wwwcg
requested changes
Feb 6, 2026
core-render-ios/Extension/KuiklyRenderViewControllerBaseDelegator.h
Outdated
Show resolved
Hide resolved
core-render-ios/Extension/KuiklyRenderViewControllerBaseDelegator.m
Outdated
Show resolved
Hide resolved
core-render-ios/Extension/KuiklyRenderViewControllerBaseDelegator.m
Outdated
Show resolved
Hide resolved
e1296af to
909ae3e
Compare
wwwcg
requested changes
Feb 6, 2026
Comment on lines
742
to
754
|
|
||
| /** | ||
| * 获取当前 KeyWindow | ||
| * 兼容 iOS 13+ 的 Scene 架构,替代废弃的 UIApplication.sharedApplication.keyWindow | ||
| */ | ||
| + (UIWindow *)keyWindow { | ||
| #if TARGET_OS_OSX | ||
| return nil; | ||
| #else | ||
| if ([UIApplication isAppExtension]) { | ||
| return nil; | ||
| } | ||
|
|
Comment on lines
289
to
316
| - (UIWindow *)viewControllerHostWindow { | ||
| #if !TARGET_OS_OSX | ||
| // 判断当前应用是否和用户交互过,避免vc初始化时UISceneActivationStateForegroundInactive导致拿到的safeAreaInsets是全零 | ||
| UIApplicationState appState = UIApplication.sharedApplication.applicationState; | ||
|
|
||
| for (UIScene *scene in UIApplication.sharedApplication.connectedScenes) { | ||
| BOOL isForegroundActive = (scene.activationState == UISceneActivationStateForegroundActive); | ||
| BOOL isForegroundInactive = (scene.activationState == UISceneActivationStateForegroundInactive); | ||
|
|
||
| // App 已活跃时只接受 Active,否则 Active 和 Inactive 都可以 | ||
| BOOL isValidState = isForegroundActive || (appState != UIApplicationStateActive && isForegroundInactive); | ||
| if (isValidState && [scene isKindOfClass:[UIWindowScene class]]) { | ||
| UIWindowScene *windowScene = (UIWindowScene *)scene; | ||
| if (!windowScene) { | ||
| continue; | ||
| } | ||
| for (UIWindow *window in windowScene.windows) { | ||
| if (window.isKeyWindow) { | ||
| return window; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| #endif | ||
| return nil; | ||
| } | ||
|
|
||
|
|
…RConvertUtil keyWindow method
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix: iOS synchronize set safeAreaInset