我在尝试拍摄照片时遇到了崩溃(前置摄像头),只有在用户使用图片模式拍摄单独的应用视频时才会失败.如果用户没有图片中的视频,一切正常.崩溃发生在这一行:
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
Run Code Online (Sandbox Code Playgroud)
有错误
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '*** -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] - inconsistent state.'
Run Code Online (Sandbox Code Playgroud)
我尝试检查手机是否在使用图片模式时无法拍摄照片,但默认的iOS相机应用程序可以拍摄照片(尽管它可能使用不同的拍照方法).stillImageOutput
而videoConnection
似乎是树立优良的和不为零.
以下是导致此崩溃的代码,以防它有所帮助.
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, …
Run Code Online (Sandbox Code Playgroud)