patternMajor
Is it still necessary to check for a front camera?
Viewed 0 times
necessarycamerafrontforstillcheck
Problem
I'm trying to clean up redundant old code, so I'm asking this general question. Since all iOS 7 devices have a front camera, would it be safe to remove the code to check if the device has a front camera? In the past this was necessary as not all devices with iOS 6 had a front camera.
It is true that Apple could theoretically release a new device without a front camera, but I doubt this would ever happen.
What is your answer though on what I should do?
It is true that Apple could theoretically release a new device without a front camera, but I doubt this would ever happen.
What is your answer though on what I should do?
BOOL deviceHasFrontCamera = NO;
NSArray *videoDevices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo];
for (AVCaptureDevice *device in videoDevices)
{
if (device.position == AVCaptureDevicePositionFront)
{
deviceHasFrontCamera = YES;
}
}Solution
According to the iOS Device Compatibility Reference, the iPhone 3GS was the only iOS 6-capable device to lack a front camera.
The same document states that your application can declare the requirement for a front-facing camera by setting the
The same document states that your application can declare the requirement for a front-facing camera by setting the
UIRequiredDeviceCapabilities key such that front-facing-camera is true. That way, you can safely strip out the camera-checking code while having your application self-document the assumption that the front camera exists.Context
StackExchange Code Review Q#56712, answer score: 22
Revisions (0)
No revisions yet.