objective c - Check which camera is currently in use in iOS Application -
i'm writing app has custom made view taking photos camera, similar apple's avcam. in it, want make button disappear , re-appear flash icon every time camera switched. ie when using front camera, flash button shouldn't there , when using should!
my code @ moment is:
avcapturedeviceposition position = [[videoinput device] position]; if (position == avcapturedevicepositionback) { self.flashbutton.hidden == yes; }
but comes error on videoinput , i'm not sure why... documentation direct me or ideas changes in code appreciated!
edit
just why come error of 'use of undeclared identifier' code:
avcapturedeviceposition position = [[videoinput device] position];
the below code might :
avcapturedeviceinput *newvideoinput; avcapturedeviceposition currentcameraposition = [[videoinput device] position]; if (currentcameraposition == avcapturedevicepositionback) { currentcameraposition = avcapturedevicepositionfront; } else { currentcameraposition = avcapturedevicepositionback; } avcapturedevice *backfacingcamera = nil; nsarray *devices = [avcapturedevice deviceswithmediatype:avmediatypevideo]; (avcapturedevice *device in devices) { if ([device position] == currentcameraposition) { backfacingcamera = device; } } newvideoinput = [[avcapturedeviceinput alloc] initwithdevice:backfacingcamera error:&error];
Comments
Post a Comment