Skip to content

Commit

Permalink
Fix iOS 11/12 builds
Browse files Browse the repository at this point in the history
  • Loading branch information
LIJI32 committed Nov 23, 2024
1 parent 150f0fc commit fe2c868
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions iOS/GBViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,18 @@ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(N
((__bridge void(^)(id))context)(change[NSKeyValueChangeNewKey]);
}

- (NSArray<NSNumber *> *)zoomFactorsForDevice:(AVCaptureDevice *)device
{
if (@available(iOS 13.0, *)) {
return device.virtualDeviceSwitchOverVideoZoomFactors;
}
double factor = device.dualCameraSwitchOverVideoZoomFactor;
if (factor == 1.0) {
return @[];
}
return @[@(factor)];
}

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
_window = [[UIWindow alloc] init];
Expand Down Expand Up @@ -308,7 +320,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
for (AVCaptureDevice *device in cameraDiscoverySession.devices) {
if ([device position] == AVCaptureDevicePositionBack) {
if (!_backCaptureDevice ||
_backCaptureDevice.virtualDeviceSwitchOverVideoZoomFactors.count < device.virtualDeviceSwitchOverVideoZoomFactors.count) {
[self zoomFactorsForDevice:_backCaptureDevice].count < [self zoomFactorsForDevice:device].count) {
_backCaptureDevice = device;
}
}
Expand All @@ -317,7 +329,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}
}

_zoomLevels = _backCaptureDevice.virtualDeviceSwitchOverVideoZoomFactors.mutableCopy;
_zoomLevels = [self zoomFactorsForDevice:_backCaptureDevice].mutableCopy;
[_zoomLevels insertObject:@1 atIndex:0];
if (_zoomLevels.count == 3 && _zoomLevels[2].doubleValue > 5.5 && _zoomLevels[1].doubleValue < 3.5) {
[_zoomLevels insertObject:@4 atIndex:2];
Expand Down

0 comments on commit fe2c868

Please sign in to comment.