当前位置:网站首页>刘海屏手机在部分页面通过[[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;
}
边栏推荐
- Learning Tai Chi Maker - mqtt Chapter 2 (V) heartbeat mechanism
- Performance optimization and implementation of video codec
- [noip2002 popularization group] cross the river pawn
- 整理网上蛋糕商城项目
- CPG 固体支持物研究:Lumiprobe通用 CPG II 型
- 【牛客网刷题系列 之 Verilog快速入门】~ 四选一多路器
- lotus v1.16.0 calibnet
- Have you finished the examination of level II cost engineer? There are also qualification regulations!
- Understanding the source of innovation II
- !‘ Cat 'is not an internal or external command, nor is it a runnable program or batch file.
猜你喜欢

DH parameters of robotics and derivation using MATLAB symbolic operation

Role of native keyword

【牛客网刷题系列 之 Verilog快速入门】~ 四选一多路器

Learn Taiji Maker - mqtt Chapter 2 (IV) esp8266 reserved message application

BioVendor sRAGE蛋白解决方案

JS 文本框失去焦点修改全半角文字和符号

Extjs library management system source code intelligent library management system source code

CpG solid support research: lumiprobe general CpG type II

metaRTC5.0编程之p2p网络穿透(stun)指南

学习太极创客 — MQTT 第二章(四)ESP8266 保留消息应用
随机推荐
Project practice! Teach you JMeter performance test hand in hand
学习太极创客 — MQTT 第二章(六)MQTT 遗嘱
Principle and implementation of SSD for target detection
wordpress zibll子比主题6.4.1开心版 免授权
109. simple chat room 12: realize client-side one-to-one chat
The short video local life section has become popular. How to grasp the new opportunities?
Dart学习——函数、类
Severe tire damage: the first rock band in the world to broadcast live on the Internet
Carboxylic acid study: lumiprobe sulfoacyanine 7 dicarboxylic acid
信息学奥赛一本通 1360:奇怪的电梯(lift)
公司为什么选择云数据库?它的魅力到底是什么!
Excel将一行的内容进行复制时,列与列之间是用制表符“\t”进行分隔的
Audio and video technology development weekly
2022 low voltage electrician examination questions and answers
Opencv实现颜色检测
2022烟花爆竹经营单位安全管理人员特种作业证考试题库及模拟考试
PHP code wechat, official account and enterprise wechat send emoticons [u+1f449]
[NOIP2002 普及组] 过河卒
2022年最新辽宁建筑八大员(标准员)考试试题及答案
PCR/qPCR研究:Lumiprobe丨dsGreen 用于实时 PCR