我是新來的Objective C,這是我在這裏發佈的第一個問題,所以這可能是世界上最簡單的問題,但我無法確定一出。UIImagePickerController with cameraOverlayView在點擊疊加中的按鈕時會聚焦
我想創建一個使用相機的iOS應用程序。我使用UIImagePickerController類來顯示相機和拍照,但我創建了一個自定義UIView,其中包含一系列覆蓋相機預覽幀的UIButton實例,使用cameraOverlayView屬性。我使用的方法把相機屏幕上使用此代碼:
- (BOOL) startCameraControllerFromViewController: (UIImagePickerController*) imagePickerController
usingDelegate: (id <UIImagePickerControllerDelegate,
UINavigationControllerDelegate>) imagePickerControllerDelegate {
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO)
|| (imagePickerController == nil)
|| (imagePickerControllerDelegate == nil))
return NO;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePickerController.mediaTypes = [[NSArray alloc] initWithObjects: (NSString *) kUTTypeImage, nil];
imagePickerController.allowsEditing = NO;
imagePickerController.showsCameraControls = NO;
imagePickerController.wantsFullScreenLayout = YES;
imagePickerController.delegate = imagePickerControllerDelegate;
self.cameraOverlayViewController = [[CameraOverlayViewController alloc] initWithImagePickerControllerDelegate:imagePickerController nibName:@"CameraOverlayView" bundle:nil];
self.cameraOverlayViewController.view.frame = CGRectMake(0, 0, imagePickerController.view.frame.size.width, imagePickerController.view.frame.size.height);
imagePickerController.cameraOverlayView = self.cameraOverlayViewController.view;
[self presentViewController:imagePickerController animated:self.showCameraAnimation completion:^(void) {
[self.view bringSubviewToFront:self.cameraOverlayViewController.view];
}];
return YES;
}
當我按下位於相機預覽窗口頂部的按鈕,相應的IBAction爲被觸發,但是底部的攝像機視圖也可以輕拍並重新聚焦。所以每次按下按鈕,我都必須手動重新調焦相機預覽才能拍攝照片。正如你可以看到我試圖使用bringSubViewToFront :,但那似乎不起作用。
當我點擊cameraOverlayView上的按鈕時,如何防止相機聚焦?
Thnx求助!
這項工作? [imagePickerController.view bringSubviewToFront:self.cameraOverlayViewController.view]; – jithinroy