摄像头横竖屏适配

This commit is contained in:
祝发冬
2022-10-14 10:37:36 +08:00
parent a0fff8e375
commit 2aa126ced3
3 changed files with 36 additions and 9 deletions
@@ -1289,9 +1289,22 @@ Strong UIImage *screenShotImage;//截图
//设置横屏
[AppDelegate sharedDefault].canFullScreen = YES;
static int isFullScreen = 3; // 3 == 全屏 1 == 竖屏
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)])
if (@available(iOS 16.0, *)) {
[self setNeedsUpdateOfSupportedInterfaceOrientations];
[self.navigationController setNeedsUpdateOfSupportedInterfaceOrientations];
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *scene = (UIWindowScene *)array[0];
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:UIInterfaceOrientationMaskLandscape];
[scene requestGeometryUpdateWithPreferences:geometryPreferences
errorHandler:^(NSError * _Nonnull error) {
NSLog(@"wuwuFQ%@", error);
}];
} else if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)])
{
NSNumber *numb=[NSNumber numberWithInteger:UIInterfaceOrientationLandscapeRight];
isFullScreen = UIInterfaceOrientationLandscapeRight;
[[UIDevice currentDevice] performSelector:@selector(setOrientation:)
withObject:numb];
@@ -1327,11 +1340,23 @@ Strong UIImage *screenShotImage;//截图
//设置竖屏
[AppDelegate sharedDefault].canFullScreen = NO;
static int isFullScreen = 1; // 3 == 全屏 1 == 竖屏
if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)])
if (@available(iOS 16.0, *)) {
[self setNeedsUpdateOfSupportedInterfaceOrientations];
[self.navigationController setNeedsUpdateOfSupportedInterfaceOrientations];
NSArray *array = [[[UIApplication sharedApplication] connectedScenes] allObjects];
UIWindowScene *scene = (UIWindowScene *)array[0];
UIWindowSceneGeometryPreferencesIOS *geometryPreferences = [[UIWindowSceneGeometryPreferencesIOS alloc] initWithInterfaceOrientations:UIInterfaceOrientationMaskPortrait];
[scene requestGeometryUpdateWithPreferences:geometryPreferences
errorHandler:^(NSError * _Nonnull error) {
NSLog(@"wuwuFQ%@", error);
}];
} else if ([[UIDevice currentDevice] respondsToSelector:@selector(setOrientation:)])
{
NSLog(@"self.interfaceOrientation%ld",(long)UIDeviceOrientationPortrait);
isFullScreen = UIDeviceOrientationPortrait;
//NSNumber *numb=[NSNumber numberWithInteger:UIDeviceOrientationPortrait];
//[[UIDevice currentDevice] performSelector:@selector(setOrientation:)
// withObject:numb];