Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion core-render-ios/Extension/Category/KRConvertUtil.m
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ + (UIEdgeInsets)currentSafeAreaInsets {
}

if (@available(iOS 11, *)) {
UIWindow *window = UIApplication.sharedApplication.windows.firstObject;
UIWindow *window = UIApplication.sharedApplication.keyWindow;
return window.safeAreaInsets;
} else {
// 在 iOS 11 之前的版本中,您需要根据需要自己计算安全边距
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,12 @@ UIKIT_EXTERN NSString *const KRPageDataSnapshotKey;
*/
- (NSString * _Nullable)turboDisplayKey;

/*
* @brief 获取业务承载KuiklyRenderViewController的window
* @return 业务承载KuiklyRenderViewController的window
*/
- (UIWindow * _Nullable)targetWindow;

@end


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,13 @@ - (NSString *)turboDisplayKey {
return nil;
}

- (UIWindow *)targetWindow {
if ([self.delegate respondsToSelector:@selector(targetWindow)]) {
return [self.delegate targetWindow];
}
return nil;
}

#pragma mark - exception handle

- (void)setExceptionBlock:(KuiklyRenderView *)view {
Expand Down
7 changes: 7 additions & 0 deletions core-render-ios/View/KuiklyRenderView.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@ UIKIT_EXTERN NSString *const KRRootViewSizeDidChangedEventKey;
*/
- (NSString * _Nullable)turboDisplayKey;


/*
* @brief 获取业务承载KuiklyRenderViewController的window
* @return 业务承载KuiklyRenderViewController的window
*/
- (UIWindow * _Nullable)targetWindow;

@end

NS_ASSUME_NONNULL_END
Expand Down
16 changes: 15 additions & 1 deletion core-render-ios/View/KuiklyRenderView.m
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,13 @@ - (NSString *)turboDisplayKey {
return nil;
}

- (UIWindow *)targetWindow {
if ([self.delegate respondsToSelector:@selector(targetWindow)]) {
return [self.delegate targetWindow];
}
return nil;
}

#pragma mark - private

- (NSDictionary *)p_generateWithParams:(NSDictionary *)params size:(CGSize)size {
Expand All @@ -219,8 +226,15 @@ - (NSDictionary *)p_generateWithParams:(NSDictionary *)params size:(CGSize)size
mParmas[KRParamKey] = params? : @{};
mParmas[KRNativeBuild] = @(2);
mParmas[KRAccessibilityRunning] = @(UIAccessibilityIsVoiceOverRunning() ? 1: 0); // 无障碍化是否开启

if (@available(iOS 11.0, *)) {
mParmas[KRSafeAreaInsets] = [KRConvertUtil stringWithInsets:[KRConvertUtil currentSafeAreaInsets]];
UIWindow *targetWindow = [self.delegate targetWindow];
if (targetWindow) {
// 业务自行传递来了Kuikly页面所设置在的目标window,则直接返回此window的安全区域值
mParmas[KRSafeAreaInsets] = [KRConvertUtil stringWithInsets:targetWindow.safeAreaInsets];
} else {
mParmas[KRSafeAreaInsets] = [KRConvertUtil stringWithInsets:[KRConvertUtil currentSafeAreaInsets]];
}
} else {
mParmas[KRSafeAreaInsets] = [KRConvertUtil stringWithInsets:UIEdgeInsetsMake([KRConvertUtil statusBarHeight], 0, 0, 0)];
// Fallback on earlier versions
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,5 +247,9 @@ - (NSString *)turboDisplayKey {
return _pageName;
}

- (UIWindow *)targetWindow {
return UIApplication.sharedApplication.keyWindow;
}


@end