跪求作者更新解决iOS16横屏问题
zengqingf opened this issue · 36 comments
用户反馈的越来越多,老板开始扣我绩效了 😭,跪求作者更新解决iOS16横屏问题
我试了下,勉强能正常使用,但还是有点问题, 还是希望作者更新下
主要就是把shouldAutorotate的方法改成手动调用
修改ZFOrientationObserver.m
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation {
// 虽然在iOS16设置里没用,但还是可以通过orientation获取到当前的旋转方向作为判断
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
UIInterfaceOrientation val = orientation;
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}
if (@available(iOS 16.0, *)) {
// 原来在shouldAutorotate里调用,iOS16改为手动调
[self ls_shouldAutorotate];
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *scene = (UIWindowScene *)array.firstObject;
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init];
[geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"];
[scene requestGeometryUpdateWithPreferences:geometryPreferences
errorHandler:^(NSError * _Nonnull error) {
NSLog(@"--------Orientation Error: %@",error);
}];
}
}
我试了下,勉强能正常使用,但还是有点问题, 还是希望作者更新下 主要就是把shouldAutorotate的方法改成手动调用 修改ZFOrientationObserver.m
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation { // 虽然在iOS16设置里没用,但还是可以通过orientation获取到当前的旋转方向作为判断 if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; UIInterfaceOrientation val = orientation; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } if (@available(iOS 16.0, *)) { // 原来在shouldAutorotate里调用,iOS16改为手动调 [self ls_shouldAutorotate]; NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = (UIWindowScene *)array.firstObject; UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init]; [geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"]; [scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { NSLog(@"--------Orientation Error: %@",error); }]; } }
横屏返回好像也有问题
[UIWindow.zf_currentViewController setNeedsUpdateOfSupportedInterfaceOrientations];
[self ls_shouldAutorotate];
这样试试
我试了下,勉强能正常使用,但还是有点问题, 还是希望作者更新下 主要就是把shouldAutorotate的方法改成手动调用 修改ZFOrientationObserver.m
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation { // 虽然在iOS16设置里没用,但还是可以通过orientation获取到当前的旋转方向作为判断 if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; UIInterfaceOrientation val = orientation; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } if (@available(iOS 16.0, *)) { // 原来在shouldAutorotate里调用,iOS16改为手动调 [self ls_shouldAutorotate]; NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = (UIWindowScene *)array.firstObject; UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init]; [geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"]; [scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { NSLog(@"--------Orientation Error: %@",error); }]; } }
横屏返回好像也有问题
[UIWindow.zf_currentViewController setNeedsUpdateOfSupportedInterfaceOrientations]; [self ls_shouldAutorotate];
这样试试
程序第一次启动横屏也无法返回?自动横屏UI错乱了
别急,我来看一下这个问题
别急,我来看一下这个问题
跪求大佬更新,升级iOS16的用户就差投诉我了
等大佬更新+1
别急,我来看一下这个问题
明天能用上吗?马上要上线了
全屏横屏播放黑屏,有声音,没画面
同样有这个问题,跪求解决。之前看了个ISSUE 在6月就有人提了这个BUG。
我倒是理解框架作者的,作者也要上班也要琢磨技术,现在iOS江河日下,不复当年,作者也要琢磨其他技术保证就业啊,我等只能耐心期待,或者自己暂时找别的办法解决。。。总之iOS16,Swift语法也变了,我这边iOS charts第三方也出了点问题我也要同时搞
我试了下,勉强能正常使用,但还是有点问题, 还是希望作者更新下 主要就是把shouldAutorotate的方法改成手动调用 修改ZFOrientationObserver.m
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation { // 虽然在iOS16设置里没用,但还是可以通过orientation获取到当前的旋转方向作为判断 if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; UIInterfaceOrientation val = orientation; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } if (@available(iOS 16.0, *)) { // 原来在shouldAutorotate里调用,iOS16改为手动调 [self ls_shouldAutorotate]; NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = (UIWindowScene *)array.firstObject; UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init]; [geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"]; [scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { NSLog(@"--------Orientation Error: %@",error); }]; } }
横屏返回好像也有问题
[UIWindow.zf_currentViewController setNeedsUpdateOfSupportedInterfaceOrientations]; [self ls_shouldAutorotate];
这样试试
测试有效, 可以暂时使用此方案解决, 等作者后续更新
作者辛苦了
我试了下,勉强能正常使用,但还是有点问题, 还是希望作者更新下 主要就是把shouldAutorotate的方法改成手动调用 修改ZFOrientationObserver.m
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation { // 虽然在iOS16设置里没用,但还是可以通过orientation获取到当前的旋转方向作为判断 if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; UIInterfaceOrientation val = orientation; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } if (@available(iOS 16.0, *)) { // 原来在shouldAutorotate里调用,iOS16改为手动调 [self ls_shouldAutorotate]; NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = (UIWindowScene *)array.firstObject; UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init]; [geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"]; [scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { NSLog(@"--------Orientation Error: %@",error); }]; } }
横屏返回好像也有问题
[UIWindow.zf_currentViewController setNeedsUpdateOfSupportedInterfaceOrientations]; [self ls_shouldAutorotate];
这样试试
测试有效, 可以暂时使用此方案解决, 等作者后续更新 作者辛苦了
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
self.rotating = YES;
[super viewWillTransitionToSize:size withTransitionCoordinator:coordinator];
if (!UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)) {
return;
}
UIInterfaceOrientation newOrientation = UIInterfaceOrientationUnknown;
if (@available(iOS 16.0, *)) {
// iOS16 需要使用 UIWindowScene 来区分横竖屏
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *scene = [array firstObject];
newOrientation = scene.interfaceOrientation;
}else{
newOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation;
}
UIInterfaceOrientation oldOrientation = _currentOrientation;
}
补充一下:在 ZFLandscapeViewController 内加上iOS16适配,横屏下按钮不太灵敏暂时还没发现问题在哪里😂
我试了下,勉强能正常使用,但还是有点问题, 还是希望作者更新下 主要就是把shouldAutorotate的方法改成手动调用 修改ZFOrientationObserver.m
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation { // 虽然在iOS16设置里没用,但还是可以通过orientation获取到当前的旋转方向作为判断 if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; UIInterfaceOrientation val = orientation; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } if (@available(iOS 16.0, *)) { // 原来在shouldAutorotate里调用,iOS16改为手动调 [self ls_shouldAutorotate]; NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = (UIWindowScene *)array.firstObject; UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init]; [geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"]; [scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { NSLog(@"--------Orientation Error: %@",error); }]; } }
横屏返回好像也有问题
[UIWindow.zf_currentViewController setNeedsUpdateOfSupportedInterfaceOrientations]; [self ls_shouldAutorotate];
这样试试
测试有效, 可以暂时使用此方案解决, 等作者后续更新 作者辛苦了
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { self.rotating = YES; [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; if (!UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)) { return; } UIInterfaceOrientation newOrientation = UIInterfaceOrientationUnknown; if (@available(iOS 16.0, *)) { // iOS16 需要使用 UIWindowScene 来区分横竖屏 NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = [array firstObject]; newOrientation = scene.interfaceOrientation; }else{ newOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation; } UIInterfaceOrientation oldOrientation = _currentOrientation; }
补充一下:在 ZFLandscapeViewController 内加上iOS16适配,横屏下按钮不太灵敏暂时还没发现问题在哪里😂
if (@available(iOS 16.0, *)) {
// 原来在shouldAutorotate里调用,iOS16改为手动调
[UIWindow.zf_currentViewController setNeedsUpdateOfSupportedInterfaceOrientations];
[self ls_shouldAutorotate];
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *scene = (UIWindowScene *)array.firstObject;
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [UIWindowSceneGeometryPreferencesIOS.alloc initWithInterfaceOrientations:1 << orientation];
[scene requestGeometryUpdateWithPreferences:geometryPreferences
errorHandler:^(NSError * _Nonnull error) {
NSLog(@"--------Orientation Error: %@",error);
}];
}
再把竖屏返回的动画去掉 暂时先这样解决
- (void)backBtnClickAction:(UIButton *)sender {
self.lockBtn.selected = NO;
self.player.lockedScreen = NO;
self.lockBtn.selected = NO;
if (self.player.orientationObserver.supportInterfaceOrientation & ZFInterfaceOrientationMaskPortrait) {
if (@available(iOS 16.0, *)) {
[self.player enterFullScreen:NO animated:NO];
} else {
[self.player enterFullScreen:NO animated:YES];
}
}
if (self.backBtnClickCallback) {
self.backBtnClickCallback();
}
}
[已解决,方案是不使用ZF中自带的全屏功能,所有的播控自定义,页面跳转采用自定义转场动画,对横屏view进行旋转,这样就不会牵扯到强制横屏相关的API了,还未解决的可以考虑下这种实现方式,现实现效果如下
2022-09-09.18.00.10.mp4
[已解决,方案是不使用ZF中自带的全屏功能,所有的播控自定义,页面跳转采用自定义转场动画,对横屏view进行旋转,这样就不会牵扯到强制横屏相关的API了,还未解决的可以考虑下这种实现方式,现实现效果如下
2022-09-09.18.00.10.mp4
就是可以发一下你转场动画的关键代码分享下吗?
我试了下,勉强能正常使用,但还是有点问题, 还是希望作者更新下 主要就是把shouldAutorotate的方法改成手动调用 修改ZFOrientationObserver.m
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation { // 虽然在iOS16设置里没用,但还是可以通过orientation获取到当前的旋转方向作为判断 if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; UIInterfaceOrientation val = orientation; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } if (@available(iOS 16.0, *)) { // 原来在shouldAutorotate里调用,iOS16改为手动调 [self ls_shouldAutorotate]; NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = (UIWindowScene *)array.firstObject; UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init]; [geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"]; [scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { NSLog(@"--------Orientation Error: %@",error); }]; } }
横屏返回好像也有问题
[UIWindow.zf_currentViewController setNeedsUpdateOfSupportedInterfaceOrientations]; [self ls_shouldAutorotate];
这样试试
测试有效, 可以暂时使用此方案解决, 等作者后续更新 作者辛苦了
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { self.rotating = YES; [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; if (!UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)) { return; } UIInterfaceOrientation newOrientation = UIInterfaceOrientationUnknown; if (@available(iOS 16.0, *)) { // iOS16 需要使用 UIWindowScene 来区分横竖屏 NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = [array firstObject]; newOrientation = scene.interfaceOrientation; }else{ newOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation; } UIInterfaceOrientation oldOrientation = _currentOrientation; }
补充一下:在 ZFLandscapeViewController 内加上iOS16适配,横屏下按钮不太灵敏暂时还没发现问题在哪里😂
if (@available(iOS 16.0, *)) { // 原来在shouldAutorotate里调用,iOS16改为手动调 [UIWindow.zf_currentViewController setNeedsUpdateOfSupportedInterfaceOrientations]; [self ls_shouldAutorotate]; NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = (UIWindowScene *)array.firstObject; UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [UIWindowSceneGeometryPreferencesIOS.alloc initWithInterfaceOrientations:1 << orientation]; [scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { NSLog(@"--------Orientation Error: %@",error); }]; }
再把竖屏返回的动画去掉 暂时先这样解决
- (void)backBtnClickAction:(UIButton *)sender {
self.lockBtn.selected = NO;
self.player.lockedScreen = NO;
self.lockBtn.selected = NO;
if (self.player.orientationObserver.supportInterfaceOrientation & ZFInterfaceOrientationMaskPortrait) {
if (@available(iOS 16.0, *)) {
[self.player enterFullScreen:NO animated:NO];
} else {
[self.player enterFullScreen:NO animated:YES];
}
}
if (self.backBtnClickCallback) {
self.backBtnClickCallback();
}
}
(void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id)coordinator
这个方法 第一次进入的时候会调用 第二次就不会调用 导致横竖屏UI不刷新 有知道原因的么
任意页面手势返回,然后横屏UI错乱有知道原因的吗?
我差不多正常了,但是有一个奇怪的问题 第一次都正常 包括进退。第二进入之后退出错乱
我不敢升级xcode14,试探性的做的时候,集合了留言的意见,还是有些状态有问题,比方说横屏不播放,或者自动横竖屏就卡住了,再加上由于不升级xcode14,所以用xcode13没有iOS16那些方法,也是麻烦事
我试了下,勉强能正常使用,但还是有点问题, 还是希望作者更新下 主要就是把shouldAutorotate的方法改成手动调用 修改ZFOrientationObserver.m
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation { // 虽然在iOS16设置里没用,但还是可以通过orientation获取到当前的旋转方向作为判断 if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) { SEL selector = NSSelectorFromString(@"setOrientation:"); NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]]; [invocation setSelector:selector]; [invocation setTarget:[UIDevice currentDevice]]; UIInterfaceOrientation val = orientation; [invocation setArgument:&val atIndex:2]; [invocation invoke]; } if (@available(iOS 16.0, *)) { // 原来在shouldAutorotate里调用,iOS16改为手动调 [self ls_shouldAutorotate]; NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = (UIWindowScene *)array.firstObject; UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init]; [geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"]; [scene requestGeometryUpdateWithPreferences:geometryPreferences errorHandler:^(NSError * _Nonnull error) { NSLog(@"--------Orientation Error: %@",error); }]; } }
横屏返回好像也有问题
[UIWindow.zf_currentViewController setNeedsUpdateOfSupportedInterfaceOrientations]; [self ls_shouldAutorotate];
这样试试
测试有效, 可以暂时使用此方案解决, 等作者后续更新 作者辛苦了
- (void)viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator { self.rotating = YES; [super viewWillTransitionToSize:size withTransitionCoordinator:coordinator]; if (!UIDeviceOrientationIsValidInterfaceOrientation([UIDevice currentDevice].orientation)) { return; } UIInterfaceOrientation newOrientation = UIInterfaceOrientationUnknown; if (@available(iOS 16.0, *)) { // iOS16 需要使用 UIWindowScene 来区分横竖屏 NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects]; UIWindowScene *scene = [array firstObject]; newOrientation = scene.interfaceOrientation; }else{ newOrientation = (UIInterfaceOrientation)[UIDevice currentDevice].orientation; } UIInterfaceOrientation oldOrientation = _currentOrientation; }
补充一下:在 ZFLandscapeViewController 内加上iOS16适配,横屏下按钮不太灵敏暂时还没发现问题在哪里😂
竖屏方向锁定开启,横屏可以返回,但 requestGeometryUpdateWithPreferences:geometryPreferences中其实没有真正的旋转过来;
竖屏方向锁定关闭,横屏返回不了,一直报错,拿到的方向一直都是unkown.
我在修改,转屏这块要大改一下,预计周末能改好
- (void)interfaceOrientation:(UIInterfaceOrientation)orientation {
// 虽然在iOS16设置里没用,但还是可以通过orientation获取到当前的旋转方向作为判断
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)]) {
SEL selector = NSSelectorFromString(@"setOrientation:");
NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDevice instanceMethodSignatureForSelector:selector]];
[invocation setSelector:selector];
[invocation setTarget:[UIDevice currentDevice]];
UIInterfaceOrientation val = orientation;
[invocation setArgument:&val atIndex:2];
[invocation invoke];
}
if (@available(iOS 16.0, *)) {
// 原来在shouldAutorotate里调用,iOS16改为手动调
[self ls_shouldAutorotate];
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *scene = (UIWindowScene *)array.firstObject;
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] init];
[geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"];
[scene requestGeometryUpdateWithPreferences:geometryPreferences
errorHandler:^(NSError * _Nonnull error) {
NSLog(@"--------Orientation Error: %@",error);
}];
}
}
请问上面的解决方法,需要升级Xcode 14才可以是吗?我这边Xcode 13.0,用上面的方法临时改一下,UIWindowSceneGeometryPreferencesIOS没找到这个类报错
Xcode13 可以这样改下,开启和关闭竖屏锁定都可以,但在xcode14上就不行。
if (@available(iOS 16.0, *)) {
@Try {
[self ls_shouldAutorotate];
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *ws = (UIWindowScene *)array.firstObject;
Class GeometryPreferences = NSClassFromString(@"UIWindowSceneGeometryPreferencesIOS");
id geometryPreferences = [[GeometryPreferences alloc]init];
[geometryPreferences setValue:@(orientation) forKey:@"interfaceOrientations"];
SEL sel_method = NSSelectorFromString(@"requestGeometryUpdateWithPreferences:errorHandler:");
void (^ErrorBlock)(NSError *err) = ^(NSError err){
NSLog(@"--------Orientation Error: %@",err);
};
if ([ws respondsToSelector:sel_method]) {
(((void ()(id, SEL,id,id))[ws methodForSelector:sel_method])(ws, sel_method,geometryPreferences,ErrorBlock));
}
} @catch (NSException *exception) {
} @finally {
}
}
已经解决了,大家拉取最新代码先验证一下,有问题反馈给我
已经解决了,大家拉取最新代码先验证一下,有问题反馈给我
demo在ZFAppDelegate.m 中 报这个错误了 辛苦作者看下
'ZFPlayer/ZFLandscapeRotationManager.h' file not found
pod install一下
拉的是4.0.3,但还是没有'ZFPlayer/ZFLandscapeRotationManager.h'
拉的是4.0.3,但还是没有'ZFPlayer/ZFLandscapeRotationManager.h'
作者还没有更新到pods索引库里面,还在测试阶段
有些人可能不清楚怎么拉代码
pod 'ZFPlayer', :git => 'https://github.com/renzifeng/ZFPlayer.git'
pod 'ZFPlayer/ControlView', :git => 'https://github.com/renzifeng/ZFPlayer.git'
pod 'ZFPlayer/AVPlayer', :git => 'https://github.com/renzifeng/ZFPlayer.git'
Swift的项目注意下,否则会导致ios16转屏失败:
Appdelegata里面的
func application(_ application: UIApplication, supportedInterfaceOrientationsFor window: UIWindow?) -> UIInterfaceOrientationMask {
let orientationMask = ZFLandscapeRotationManager.supportedInterfaceOrientations(for: window)
if orientationMask != [] {
// ios16的BUG
// 需要用oc强转成UIInterfaceOrientationMask
// Swift语法return会导致转屏失败
let mask = OCHelper.orientationMask(fromZFPlayerOrientationMask: orientationMask)
return mask
}
return .portrait
}
OCHelper imp:
#import "OCHelper.h"
@implementation OCHelper
+ (UIInterfaceOrientationMask)orientationMaskFromZFPlayerOrientationMask:(ZFInterfaceOrientationMask)mask {
return (UIInterfaceOrientationMask)mask;
}
@end
拉的是4.0.3,但还是没有'ZFPlayer/ZFLandscapeRotationManager.h'
作者还没有更新到pods索引库里面,还在测试阶段
啥时候能更新下啊 ?最近发版本
4.1.0还没发布吗 cocoapods官网还是4.0.3的 没有新增Rotatiion相关代码
已发布4.1.0
已经解决了,大家拉取最新代码先验证一下,有问题反馈给我
设置关闭自动旋转 self.player.allowOrentitaionRotation = NO 之后 ,手动点击旋转功能也失效了
ZFLandscapeViewController_iOS15 内存泄露 横屏后没释放