当前位置:网站首页>刘海屏手机在部分页面通过[[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;
}
边栏推荐
- 【牛客网刷题系列 之 Verilog快速入门】~ 四选一多路器
- Where does the storm go? Whose pot is the weather forecast wrong?
- Store inventory management system source code
- Flexible IP network test tool -- x-launch
- openssl客户端编程:一个不起眼的函数导致的SSL会话失败问题
- 氨基染料研究:Lumiprobe FAM 胺,6-异构体
- Simple usage of GSAP
- 2022年最新辽宁建筑八大员(标准员)考试试题及答案
- Binary sort tree: BST
- cgo+gSoap+onvif学习总结:8、arm平台交叉编译运行及常见问题总结
猜你喜欢

活性染料研究:Lumiprobe AF594 NHS 酯,5-异构体

如何学习可编程逻辑控制器(PLC)?

A doctor's 22 years in Huawei (full of dry goods)
![[JVM series] JVM tuning](/img/e1/086f76ec6c9b56d97430b1e073f5a6.png)
[JVM series] JVM tuning

S32ds jump to defaultisr

2022 safety officer-b certificate examination question bank and answers

Store inventory management system source code

quartus 复制IP核

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

店铺进销存管理系统源码
随机推荐
On the necessity of building a video surveillance convergence platform and its scenario application
Latest Windows version 5.0.14 of redis
Generate QR code in wechat applet
Metartc5.0 API programming guide (I)
How high is the gold content of grade II cost engineer certificate? Just look at this
JS text box loses focus to modify width text and symbols
氨基染料研究:Lumiprobe FAM 胺,6-异构体
无线传感器网络学习笔记(一)
Learning Tai Chi Maker - mqtt Chapter II (VI) mqtt wills
Pcr/qpcr research: lumiprobe dsgreen is used for real-time PCR
Have you finished the examination of level II cost engineer? There are also qualification regulations!
Reactive dye research: lumiprobe af594 NHS ester, 5-isomer
Simple usage of GSAP
[early knowledge of activities] list of recent activities of livevideostack
Feign implements path escape through custom annotations
Blocking, non blocking, IO multiplexing select\poll\epoll
吴恩达深度学习测验题:deeplearning.ai-week1-quiz
学习太极创客 — MQTT 第二章(四)ESP8266 保留消息应用
深度强化学习笔记
Unity delegate