2011-12-09 25 views

回答

9

那麼它說,在文檔中:

此方法拋出NSInvalidArgumentException如果jpegSampleBuffer是JPEG格式NULL與否。

因此,這可能意味着JPEG處理器預期的數據不在緩衝區中(如果您拍照太快)。

因此,要麼你檢查imageSampleBufferNULL或我做了什麼:我把整個事件封裝在if語句中檢查:CMSampleBufferIsValid(imageSampleBuffer),但不知道這是否是保護這一點的正確方法。文檔有點稀疏。

+0

這有什麼更新? – MobileMon

4

像往常一樣,檢查錯誤。

[self.stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection 
                completionHandler: ^(CMSampleBufferRef imageSampleBuffer, NSError *error) 
{ 
    if (!error) { 

而且只是櫃面,這裏是(IBAction)didTakePhoto

if (self.captureSession.isRunning) { 
    [self captureNow]; 
     //Custom capture method. 
} 
相關問題