当前位置:网站首页>刘海屏手机在部分页面通过[[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;
}
边栏推荐
- 2022西式面点师(高级)考试试题模拟考试平台操作
- Idle interrupt cannot be cleared
- 如何从零设计一款牛逼的高并发架构(建议收藏)
- Analysis of distributed transaction solution Seata golang
- Learn Taiji Maker - mqtt Chapter 2 (IV) esp8266 reserved message application
- [early knowledge of activities] list of recent activities of livevideostack
- 2022新版nft源码中国元宇宙数字藏品艺术品交易平台源码
- 使用class toplevel的messagebox时,窗口弹出问题。
- Principle and implementation of SSD for target detection
- 项目经理考完PMP就够了?不是的!
猜你喜欢

openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题

On the necessity of building a video surveillance convergence platform and its scenario application

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

Don't roll! How to reproduce a paper with high quality?

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

CI & CD must be known!

wordpress zibll子比主题6.4.1开心版 免授权

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

Project practice! Teach you JMeter performance test hand in hand

大促场景下,如何做好网关高可用防护
随机推荐
Study on modified triphosphate: lumiprobe amino-11-ddutp
Is it enough for the project manager to finish the PMP? no, it isn't!
2022 low voltage electrician examination questions and answers
Analysis of distributed transaction solution Seata golang
How high is the gold content of grade II cost engineer certificate? Just look at this
Simulation questions and answers of the latest national fire-fighting facility operators (primary fire-fighting facility operators) in 2022
[microservices openfeign] openfeign quick start service invocation based on feign
CPG 固体支持物研究:Lumiprobe通用 CPG II 型
CpG solid support research: lumiprobe general CpG type II
2022西式面点师(高级)考试试题模拟考试平台操作
Metartc5.0 API programming guide (I)
乔布斯在斯坦福大学的演讲稿——Follow your heart
Extjs library management system source code intelligent library management system source code
2022电力电缆判断题模拟考试平台操作
Interview: what are the similarities and differences between abstract classes and interfaces?
【JVM系列】JVM调优
2022新版nft源码中国元宇宙数字藏品艺术品交易平台源码
Realizing color detection with OpenCV
Sorting out some topics of modern exchange principle MOOC
mysql----where 1=1是什么意思