我收到了上述错误。有人可以向我解释这意味着什么以及如何解决它?我的代码如下:
UIButton *btn = (UIButton *)sender;
__weak UIButton *weakBtn = btn;
btn.enabled = NO;
AVCaptureConnection *videoConnection = nil;
for (AVCaptureConnection *connection in self.stillImageOutput.connections) {
for (AVCaptureInputPort *port in [connection inputPorts]) {
if ([[port mediaType] isEqual:AVMediaTypeVideo]) {
videoConnection = connection;
break;
}
}
if (videoConnection) {
break;
}
}
[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error) {
NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];
UIImage *image = [[UIImage alloc] initWithData:imageData];
[self pushImagePreviewVCWithImage:image];
// UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
weakBtn.enabled = YES;
根据碰撞学的说法,它正在破坏if(videoConnection){break; }
我一直在努力寻找解决方案。我还发现了一个同样崩溃的教程,但它没有修复。 http://www.musicalgeometry.com/?p=1297
谢谢!
这是错误:
0 CoreFoundation 0x00000001838602d8 __exceptionPreprocess
1 libobjc.A.dylib 0x000000019552c0e4 objc_exception_throw
2 AVFoundation 0x00000001820c17a4 -[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:]
3 First Derm 0x000000010011fff4 -[CameraOverlayVC captureNow:] (CameraOverlayVC.m:124)
4 UIKit 0x000000018830d398 -[UIApplication sendAction:to:from:forEvent:]
5 UIKit 0x00000001882f6474 -[UIControl _sendActionsForEvents:withEvent:]
6 UIKit 0x000000018830cd34 -[UIControl touchesEnded:withEvent:]
7 UIKit 0x000000018830c9c0 -[UIWindow _sendTouchesForEvent:]
8 UIKit 0x0000000188305efc -[UIWindow sendEvent:]
9 UIKit 0x00000001882d9120 -[UIApplication sendEvent:]
10 UIKit 0x000000018857a2b8 _UIApplicationHandleEventFromQueueEvent
11 UIKit 0x00000001882d7634 _UIApplicationHandleEventQueue
12 CoreFoundation 0x0000000183818240 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
13 CoreFoundation 0x00000001838174e4 __CFRunLoopDoSources0
14 CoreFoundation 0x0000000183815594 __CFRunLoopRun
15 CoreFoundation 0x00000001837412d4 CFRunLoopRunSpecific
16 GraphicsServices 0x000000018d1976fc GSEventRunModal
17 UIKit 0x000000018833ef40 UIApplicationMain
18 First Derm 0x00000001000cbed8 main (main.m:14)
19 libdyld.dylib 0x0000000195bd6a08 start
答案 0 :(得分:1)
这就是我在项目中的表现,而且效果很好。
定义自定义序列队列以在后台处理此问题
观察价值的KVO模式。
您可以参考我的示例课程:https://github.com/htaiwan/CameraSnapShot