Немодален UIImagePickerController, докоснете за фокусиране не работи

Използвам UIImagePickerController в немодална настройка, като тази:

UIImagePickerController *_imagePickerVC = // init the VC with the main camera as the source
[_mainCameraPreviewContainer addSubview:_imagePickerVC.view];
[_mainCameraPreviewContainer bringSubviewToFront:_imagePickerVC.view];

Това работи и мога да правя снимки, но не мога да докосна зоната за визуализация, за да накарам камерата да фокусира върху тази точка. Опитах се да поправя това, като добавих един или двата от тези 2 реда:

_imagePickerVC.showsCameraControls = NO;
_imagePickerVC.view.userInteractionEnabled = YES;

но няма късмет. Когато го накарам да показва контролите на камерата, получавам бутона за режим на светкавица и бутона за избор на камера, но тези бутони също не могат да се докосват. Възможно ли е да накарам крана за фокусиране да работи в моята ситуация?


person TotoroTotoro    schedule 02.03.2013    source източник


Отговори (3)


Повторих вашия код и докоснете, за да фокусирате и бутоните работят. (iOS 5.1, 6.1).

- (IBAction)buttonTap:(id)sender {
    if (!_imagePickerVC)
    {
        _imagePickerVC = [UIImagePickerController new];
        _imagePickerVC.sourceType = UIImagePickerControllerSourceTypeCamera;
    }

    [self.view addSubview:_imagePickerVC.view];
    [self.view bringSubviewToFront:_imagePickerVC.view];
}

Уверете се, че mainCameraPreviewContainer.userInteractionEnabled == YES.

person Sergey Kuryanov    schedule 13.03.2013
comment
Това беше, проблемът беше mainCameraPreviewContainer.userInteractionEnabled. Мерси човече! - person TotoroTotoro; 16.03.2013

http://jcuz.wordpress.com/2010/02/17/pickerfocus/ Можете да опитате това.

Бих ви предложил да внедрите с помощта на AVfoundation. Той е по-лесен и по-гъвкав. използване на AVFoundation ios AVFoundation докоснете, за да фокусирате

person Pushpak Narasimhan    schedule 10.03.2013

Опитайте това и ми кажете..

_imagePickerVC.view.userInteractionEnabled = YES;
UIPanGestureRecognizer *pgr = [[UITapGestureRecognizer alloc] 
                               initWithTarget:self action:@selector(handleTap:)];

[_imagePickerVC addGestureRecognizer:pgr];
[pgr release];


-(void)handleTap{
    AVCaptureDevice *device = [[self captureInput] device];

    NSError *error;

     if ([device isFocusModeSupported:AVCaptureFocusModeAutoFocus] &&
         [device isFocusPointOfInterestSupported])
     {
         if ([device lockForConfiguration:&error]) {
             [device setFocusPointOfInterest:point];

        CGPoint point = [touch locationInView:self.cameraView];
    point.x /= self.cameraView.frame.size.width;
    point.y /= self.cameraView.frame.size.height;
    [self focusAtPoint:point];

             [device unlockForConfiguration];
         } else {
             NSLog(@"Error: %@", error);
         }
     }
}
person Arun    schedule 15.03.2013