사진을 찍으려고 할 때 (전면 카메라), 사용자가 사진 모드에서 사진을 별도로 사용할 때만 오류가 발생합니다. apps 비디오. 사용자가 사진 속의 그림 속의 비디오를 가지고 있지 않다면 모든 것이 잘 작동합니다. 충돌이 줄에 발생합니다 오류iOS NSInternalInconsistencyException 앱이 iOS9 Picture in Picture 모드를 사용하는 동안 사진을 찍는 중
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] - inconsistent state.'
내가 사진 모드에서 사진을 사용하는 동안 전화를 그냥 일반적으로 사진을 찍을 수없는 경우 확인 시도와
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
하지만 기본 아이폰 OS 카메라 앱은 사진을 잘 찍을 수 있습니다 (사진을 찍는 다른 방법을 사용하기는하지만). stillImageOutput
및 videoConnection
은 잘 설정되어 있으며 0이 아닙니다.
다음은 도움이 될 수 있도록이 충돌을 일으키는 코드입니다.
avCaptureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice* cameraDevice = [GS60_FriendFeed_ScreenshotSelfie_Preview_View frontFacingCameraIfAvailable];
avCaptureSession.sessionPreset = avCaptureSessionPresetString;
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:cameraDevice error:&error];
if (!input) {
NSLog(@"ERROR: trying to open camera: %@", error);
}
[avCaptureSession addInput:input];
AVCaptureStillImageOutput* stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys: AVVideoCodecJPEG, AVVideoCodecKey, nil];
[stillImageOutput setOutputSettings:outputSettings];
[avCaptureSession addOutput:stillImageOutput];
[avCaptureSession startRunning];
및 그림에서 그림이 우리가 할 수 없음을 감지하는 방법을 알고, 열려있는 동안이 방법을 사용할 수없는 경우 나중에
AVCaptureConnection* videoConnection = nil;
AVCaptureStillImageOutput* stillImageOutput = [[avCaptureSession outputs] objectAtIndex:0];
for (AVCaptureConnection* connection in stillImageOutput.connections) {
for (AVCaptureInputPort *port in [connection inputPorts]) {
if ([[port mediaType] isEqual:AVMediaTypeVideo]) {
videoConnection = connection;
break;
}
}
if (videoConnection) { break; }
}
UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
AVCaptureVideoOrientation avcaptureOrientation = AVCaptureVideoOrientationPortrait;
if(orientation == UIInterfaceOrientationUnknown) {
avcaptureOrientation = AVCaptureVideoOrientationPortrait;
} else if(orientation == UIInterfaceOrientationPortrait) {
avcaptureOrientation = AVCaptureVideoOrientationPortrait;
} else if(orientation == UIInterfaceOrientationPortraitUpsideDown) {
avcaptureOrientation = AVCaptureVideoOrientationPortraitUpsideDown;
} else if(orientation == UIInterfaceOrientationLandscapeLeft) {
avcaptureOrientation = AVCaptureVideoOrientationLandscapeLeft;
} else if(orientation == UIInterfaceOrientationLandscapeRight) {
avcaptureOrientation = AVCaptureVideoOrientationLandscapeRight;
}
[videoConnection setVideoOrientation:avcaptureOrientation];
//this line flips the image so it uses exactly what the preview shows
[videoConnection setVideoMirrored:YES];
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
...
나는하지만 사진을 찍을 수있을 것을 선호 그것을 가져 가면 여전히 도움이 될 것입니다.
도움 주셔서 감사합니다.
해결 방법을 찾으셨습니까? – stevekohls