Disable Auto Focus on iPhone 3G S

I want to disable autofocus on iPhone 3G S.

How can I do this programmatically?

I used a custom UIImagePickerController for my camera app. I don't need this feature in my application.

please help me.

+2


source to share


2 answers


The following code should work for what you want:

NSArray *devices = [AVCaptureDevice devices];
NSError *error;
for (AVCaptureDevice *device in devices) {
    if (([device hasMediaType:AVMediaTypeVideo]) && 
        ([device position] == AVCaptureDevicePositionBack) ) {
        [device lockForConfiguration:&error];
         if ([device isFocusModeSupported:AVCaptureFocusModeLocked]) {
         device.focusMode = AVCaptureFocusModeLocked;
         NSLog(@"Focus locked");
         }

        [device unlockForConfiguration];
    }
}

      



Visible here !

+1


source


Generally, your application should not change this setting, if your users do not want to use autofocus, then they can disable it, but your application should not make a choice for them.



Is there a good reason why you need to control this? Does this interfere with your desired functionality in some way?

0


source







All Articles