当前位置:网站首页>刘海屏手机在部分页面通过[[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom得到底部安全区高度为0问题
刘海屏手机在部分页面通过[[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom得到底部安全区高度为0问题
2022-06-28 05:06:00 【郏国上】
刘海屏手机在部分页面通过[[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom得到底部安全区高度为0问题,如何解决?
如我们在播放器SelVideoPlayer中获取到刘海屏手机底部安全区高度为0,我顶部安全区也是0。正如这样下面的定义:
#define kMainTopHeight ({
float space = 64.0; if (@available(iOS 11.0, *)) space = ([[UIApplication sharedApplication] delegate].window.safeAreaInsets.top+44); (space); })
#define kMainBottomHeight ({
float space = 49.0; if (@available(iOS 11.0, *)) space = ([[UIApplication sharedApplication] delegate].window.safeAreaInsets.bottom + 49); (space); })
分析原因应该是窗口的问题。那如何解决呢?
可以通过重新获取keyWindow来正确找到底部安全高度和顶部安全区高度。
#define Base_BottomHeight ([FMConfig config].safeBottomHeight)
// 底部安全区域高度
#define BR_BOTTOM_MARGIN \ ({
CGFloat safeBottomHeight = 0;\ if (@available(iOS 11.0, *)) {
\ safeBottomHeight = BRGetKeyWindow().safeAreaInsets.bottom;\ }\ (safeBottomHeight);})
/** 获取 keyWindow */
static inline UIWindow *BRGetKeyWindow(void) {
UIWindow *keyWindow = nil;
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 130000 // 编译时检查SDK版本:Xcode11+编译会调用(iOS SDK 13.0 以后版本的处理)
if (@available(iOS 13.0, *)) {
NSSet<UIScene *> *connectedScenes = [UIApplication sharedApplication].connectedScenes;
for (UIScene *scene in connectedScenes) {
if (scene.activationState == UISceneActivationStateForegroundActive && [scene isKindOfClass:[UIWindowScene class]]) {
UIWindowScene *windowScene = (UIWindowScene *)scene;
for (UIWindow *window in windowScene.windows) {
if (window.isKeyWindow) {
keyWindow = window;
break;
}
}
}
}
} else
#endif
{
#if __IPHONE_OS_VERSION_MIN_REQUIRED < 130000
return [UIApplication sharedApplication].keyWindow;
#endif
}
return keyWindow;
}
边栏推荐
- Feign remote call fallback callback failed, no effect
- The short video local life section has become popular. How to grasp the new opportunities?
- BioVendor sRAGE Elisa试剂盒化学性质和技术研究
- Learning Tai Chi Maker - mqtt Chapter 2 (V) heartbeat mechanism
- Performance optimization and implementation of video codec
- Dart learning - functions, classes
- JS 文本框失去焦点修改全半角文字和符号
- Blocking, non blocking, IO multiplexing select\poll\epoll
- Assembly common instructions
- [JVM series] JVM tuning
猜你喜欢

!‘ Cat 'is not an internal or external command, nor is it a runnable program or batch file.

Carboxylic acid study: lumiprobe sulfoacyanine 7 dicarboxylic acid

开关电源电压型与电流型控制

Feign通过自定义注解实现路径的转义

sqlmap工具使用手册

The number of small stores in Suning has dropped sharply by 428 in one year. Zhangkangyang, the son of Zhang Jindong, is the actual controller

How to do a good job of gateway high availability protection in the big promotion scenario

DH parameters of robotics and derivation using MATLAB symbolic operation

2022年最新辽宁建筑八大员(标准员)考试试题及答案

S32ds jump to defaultisr
随机推荐
吴恩达深度学习测验题:deeplearning.ai-week1-quiz
Project practice! Teach you JMeter performance test hand in hand
Extjs图书管理系统源码 智能化图书管理系统源码
Feign implements path escape through custom annotations
How to do a good job of gateway high availability protection in the big promotion scenario
大促场景下,如何做好网关高可用防护
How high is the gold content of grade II cost engineer certificate? Just look at this
学习太极创客 — MQTT 第二章(五)心跳机制
Principle and implementation of SSD for target detection
2022烟花爆竹经营单位安全管理人员特种作业证考试题库及模拟考试
羧酸研究:Lumiprobe 磺基花青7二羧酸
2022 low voltage electrician examination questions and answers
Realizing color detection with OpenCV
Lumiprobe细胞成像分析:PKH26 细胞膜标记试剂盒
Redis 的 最新windows 版本 5.0.14
QCOM LCD调试
lotus v1.16.0 calibnet
Assembly common instructions
Unity out ref params
电源插座是如何传输电的?困扰小伙伴这么多年的简单问题