使用AVCam demo,我试图通过在AVCamViewController.m中进行以下更改,在实际拍摄照片之前添加5秒的延迟:
- (IBAction)captureStillImage:(id)sender
{
// Capture a still image
[[self stillButton] setEnabled:NO];
// delay picture capture by 5 seconds
myTimer = [NSTimer scheduledTimerWithTimeInterval: 5.0
target: self
selector: @selector(pictureTimer:)
userInfo: nil
repeats: NO];
}
- (void) pictureTimer: (NSTimer *) timer {
[[self captureManager] captureStillImage];
}
然而,AVCamCaptureManager :: captureStillImage中的完成处理程序似乎永远不会被调用(我从未看到“captureStillImage完成处理程序”日志消息):
- (void) captureStillImage
{
AVCaptureConnection *stillImageConnection = [AVCamUtilities connectionWithMediaType:AVMediaTypeVideo fromConnections:[[self stillImageOutput] connections]];
if ([stillImageConnection isVideoOrientationSupported])
[stillImageConnection setVideoOrientation:orientation];
NSLog(@"captureStillImage");
[[self stillImageOutput] captureStillImageAsynchronouslyFromConnection:stillImageConnection
completionHandler:^(CMSampleBufferRef imageDataSampleBuffer, NSError *error) {
NSLog(@"captureStillImage completion handler");
使用NSTimer会不起作用吗?