2013-12-20 22 views
3

我想讀QR碼斑馬線之間startRunning:AVCaptureSession不能調用beginConfiguration/commitConfiguration

self.capture = [[ZXCapture alloc] init]; 
self.capture.rotation = 90.0f; 

// Use the back camera 
self.capture.delegate = self; 
self.capture.camera = self.capture.back; 

self.capture.layer.frame = self.view.bounds; 
[self.view.layer addSublayer:self.capture.layer]; 

我得到這個錯誤:

*終止應用程序由於未捕獲的異常'NSGenericException',原因:'* AVCaptureSession無法啓動在調用beginConfiguration/commitConfiguration之間運行'

回答

1

修復建議:

進入[ZXCapture開始],看看評論的dispathc_asyn部分:

// NSLog(@"start running"); 
// dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ 
     [self.session startRunning]; 
// }); 

我不會再崩潰,但隨後你會阻止你的主線程的時間會話需求開始 - >修補程序,直到來自zxing的人拿出一個解決方案。

2

它可以工作,如果是的話

self.capture = [[ZXCapture alloc] init]; 
self.capture.rotation = 90.0f; 

// Use the back camera 

self.capture.camera = self.capture.back; 

self.capture.layer.frame = self.view.bounds; 
[self.view.layer addSublayer:self.capture.layer]; 

self.capture.delegate = self; // this must be last.