저는 (카메라 앱과 같은) 사진 촬영을 시뮬레이트하는 AV Foundation 앱이 있습니다. 일반적으로 다음은 나를 위해 작동하지만이 경우에는 아닙니다."사진 찍기"화면을 시뮬레이션하십시오.
이 코드는 내 View Controller의 동작 내에서 실행됩니다. 그것은 AVCaptureVideoPreviewLayer가 첨부 된 하나의 전체 화면 UIView (videoPreviewLayer)를 포함합니다. 애니메이션은 실행되지만 아무 것도 표시되지 않습니다. ARC, iOS 6, iPhone 4S, iPad3을 사용 중입니다. 추가 조사 후
// Setup our preview layer so that we can display video from the camera
captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:self.captureSession];
CALayer *viewLayer = videoPreviewView.layer;
viewLayer.masksToBounds = YES;
captureVideoPreviewLayer.frame = videoPreviewView.bounds;
[viewLayer insertSublayer:captureVideoPreviewLayer below:[[viewLayer sublayers] objectAtIndex:0]];
참고은 플래시가 간헐적으로하지만 발생 : 여기
// Flash the screen white and fade it out
UIView *flashView = [[UIView alloc] initWithFrame:[[self videoPreviewView] frame]];
[flashView setBackgroundColor:[UIColor whiteColor]];
[[[self view] window] addSubview:flashView];
[UIView animateWithDuration:1.f
animations:^{
[flashView setAlpha:0.f];
}
completion:^(BOOL finished){
[flashView removeFromSuperview];
}
];
내가 AVCaptureVideoPreviewLayer를 부착하는 방법입니다. 일반적으로 시작해야 약 5-10 초 후에 표시되는 것으로 보입니다. 한 번 코드를 호출하더라도 빠르게 연속해서 두 번 실행되는 것을 보았습니다.