#import <objc/message.h>
#import <ZFPlayer/ZFPlayerController.h>
BOOL zf_isFullscreenOfFixSafeArea = NO;
API_AVAILABLE(ios(13.0)) @protocol _UIViewControllerPrivateMethodsProtocol <NSObject>
- (void)_setContentOverlayInsets:(UIEdgeInsets)insets andLeftMargin:(CGFloat)leftMargin rightMargin:(CGFloat)rightMargin;
@end
@implementation UIViewController (ZFPlayerFixSafeArea)
- (void)zf_setContentOverlayInsets:(UIEdgeInsets)insets andLeftMargin:(CGFloat)leftMargin rightMargin:(CGFloat)rightMargin {
if (zf_isFullscreenOfFixSafeArea == NO) {
[self zf_setContentOverlayInsets:insets andLeftMargin:leftMargin rightMargin:rightMargin];
}
}
@end
API_AVAILABLE(ios(13.0)) @implementation ZFOrientationObserver (ZFPlayerFixSafeArea)
+ (void)initialize {
if ( @available(iOS 13.0, *) ) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
Class cls = UIViewController.class;
SEL originalSelector = @selector(_setContentOverlayInsets:andLeftMargin:rightMargin:);
SEL swizzledSelector = @selector(zf_setContentOverlayInsets:andLeftMargin:rightMargin:);
Method originalMethod = class_getInstanceMethod(cls, originalSelector);
Method swizzledMethod = class_getInstanceMethod(cls, swizzledSelector);
method_exchangeImplementations(originalMethod, swizzledMethod);
Class pc_class = ZFPlayerController.class;
SEL pc_originalSelector = @selector(enterFullScreen:animated:completion:);
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wundeclared-selector"
SEL pc_swizzledSelector = @selector(zf_enterFullScreen:animated:completion:);
#pragma clang diagnostic pop
Method pc_originalMethod = class_getInstanceMethod(pc_class, pc_originalSelector);
Method pc_swizzledMethod = class_getInstanceMethod(pc_class, pc_swizzledSelector);
method_exchangeImplementations(pc_originalMethod, pc_swizzledMethod);
});
}
}
@end
API_AVAILABLE(ios(13.0)) @implementation ZFPlayerController (ZFPlayerFixSafeArea)
- (void)zf_enterFullScreen:(BOOL)fullScreen animated:(BOOL)animated completion:(void (^ _Nullable)(void))completion {
zf_isFullscreenOfFixSafeArea = fullScreen;
[self zf_enterFullScreen:fullScreen animated:animated completion:completion];
}
@end
iOS:多window横竖屏Bug:全屏后推到后台,再次打开,列表ui偏移了
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。
推荐阅读更多精彩内容
- Android Opencv 4.2 摄像头二次开发之 横竖屏切换,前后摄像头切换,铺满全屏问题,相机无法启动问题...
- 今天项目中遇到一个问题,因为我们的项目有几个视频播放的界面,所以避不开与全屏/半屏按钮、锁屏/解屏按钮、方向传感横...
- 因业务需要,视频需要横、竖屏切换,横屏状态需要全屏、竖屏不需要。坑已填满,欢迎指导。 横竖屏核心方法: 一:动态设...
- 需求,xform开发,尽量不依赖各平台实现,不用什么渲染技术,只在一些如摄像头调用的地方才写些平台相关的代码; A...