문제 설명
사진 촬영 후 사진 사용 또는 재촬영을 선택할 수 없습니다. (After Taking Picture cannot select Use Photo or Retake)
iOS 7용 앱을 업데이트하려고 하는데 맞춤 오버레이에 문제가 있습니다. 오버레이는 내가 사진의 구도를 잡을 때 사용하는 이미지입니다(라이브 및 전체 해상도 버전을 사용하여 카메라 롤의 최종 결과 구도를 잡기). 문제는 이제 iOS 7에서 오버레이가 하단에 투명하지만 일반 "사진 찍기" 버튼에 대한 액세스를 제공하지만 어떤 이유로 "사진 사용" 또는 "다시 찍기" 버튼을 탭할 수 없다는 것입니다. 사진이 찍힌 후에 나오는 것입니다. 다음은 뷰 컨트롤러를 호출하는 코드 스니펫입니다.
‑ (IBAction)takePhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = YES;
// Overlay Creation
UIView* overlayView = [[UIView alloc] initWithFrame:picker.view.frame];
overlayView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"PBOverlayView.png"]];
[overlayView.layer setOpaque:NO];
overlayView.opaque = NO;
picker.cameraOverlayView = overlayView;
[self presentViewController:picker animated:YES completion:NULL];
}
## 참조 솔루션 #### 방법 1:
Another approach could be to observe the notifications when the ImagePicker changes state and remove (or disable) your overlay when you move into the "Use Photo" screen.
‑ (void) addPhotoObservers {
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeCameraOverlay) name:@"_UIImagePickerControllerUserDidCaptureItem" object:nil ];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(addCameraOverlay) name:@"_UIImagePickerControllerUserDidRejectItem" object:nil ];
}
‑ (void) removePhotoObservers {
[[NSNotificationCenter defaultCenter] removeObserver:self];
}
‑(void)addCameraOverlay {
if (self.cameraPicker) {
self.cameraPicker.cameraOverlayView = self.myCameraOverlayView;
}
}
‑(void)removeCameraOverlay {
if (self.cameraPicker) {
self.cameraPicker.cameraOverlayView = nil;
}
}
방법 2:
You could set User Enteraction Enabled
to NO
on Overlay View ;) works for me
방법 3:
Your problem: When you initialised the overlayView, you've set the frame to be the same size as that of the picker. UIView* overlayView = [[UIView alloc] initWithFrame:picker.view.frame];
Explanation: Before capturing an image, the camera buttons are in the foreground of the overlayView, so that there's no issue pressing them. After capturing an image (on the "retake/use preview page"), the overlayView is the one to be in the foreground, thus blocking the access to the buttons. I know this to be an issue on iOS7, and not sure about other versions.
Possible solutions: Since this is a native problem within Apple's UIImagePickerController, I can only think of two solutions: (1) If possible, configure the overlayView to have a shorter frame which doesn't cover the bottom of the picker; (2) If you need the overlay to cover these buttons, you still have the exhausting option of configuring self.imagePicker.showsCameraControls = NO;
but then you'd have to customize ALL of the camera behaviour (you can find many examples for that on the web).
방법 4:
After taking a photo, or animation on your overlay is done, i made it work by removing the overlay from its superview.
[UIView animateWithDuration:1
delay:1
options:UIViewAnimationOptionCurveEaseOut
animations:^{
} completion:^(BOOL finished) {
[self.view removeFromSuperview];
}];
(by PorthosJon、joneswah、Vahan、o.shnn、amdstorm)