How to automatically take a picture without pressing the phototaken button on the imagepickercontroller?

后端 未结 3 1455
滥情空心
滥情空心 2021-01-14 13:47

In my project, I need to take pictures automatically every one minute. But I can\'t find out any solutions.

This is the code which I implemented but it doesn\'t work

3条回答
  •  庸人自扰
    2021-01-14 14:24

    You can call the method - (void)takePicture; of UIImagePickerController to take a picture programmatically. You can call it every one minute using a timer for example.

    Edit

    You should display the camera interface first (more info here). You can do this in the method showCameraUI. You should also keep a reference to the created UIImagePickerController.

    - (IBAction) showCameraUI
    {
        UIImagePickerController *picker;
        // create and display picker
    
       self.imagePicker = imagePicker;
       [NSTimer scheduledTimerWithTimeInterval:4.0
                                 target:self
                               selector: @selector(targetMethod)
                               userInfo:nil
                                repeats:YES];
    }
    
    - (void)targetMethod
    {
        [self.picker takePicture];
        // ...
    }
    

提交回复
热议问题