Ios 在AVCam演示中延迟图片捕获

Ios 在AVCam演示中延迟图片捕获,ios,nstimer,avcam,Ios,Nstimer,Avcam,使用,我试图通过在AVCamViewController.m中进行以下更改,在实际拍摄照片之前添加5秒的延迟: - (IBAction)captureStillImage:(id)sender { // Capture a still image [[self stillButton] setEnabled:NO]; // delay picture capture by 5 seconds myTimer = [NSTimer scheduledTimerWithTi

使用,我试图通过在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完成处理程序”日志消息):


使用NSTimer会不会不起作用?

控制台中是否打印出运行时错误?是否在“
@interface
”文件中声明了“pictureTimer:”方法?没有,我没有看到任何运行时错误。它在接口文件中声明。
- (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");