UIImagePickerController TakePicture方法未保存到相机胶卷

时间:2013-01-28 09:12:06

标签: ios xcode uiimagepickercontroller

感谢您的阅读, 我正在制作一个相机计时器应用程序,当计时器点击0时,意图拍摄一张照片。但事实并非如此。 :C

HERE是显示PickerController和我的新控件的Overlay的代码。 (ViewDidLoad方法加载时太早。)

-(void)viewDidAppear:(BOOL)animated{
    overlayView.hidden = false;
imagePicker = [[UIImagePickerController  alloc] init];
imagePicker.delegate = self;
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
[self presentViewController:imagePicker animated:YES completion:NULL];
imagePicker.showsCameraControls = NO;
imagePicker.cameraOverlayView = overlayView;

}

HERE是计时器达到0并且要拍摄照片时的代码。

//cameraTimeInt is the timer//
if(cameraTimeInt ==0){

//timerDisplay is the picture displaying the countdown to 0//
        [timerDisplay setImage:NULL];

        [imagePicker takePicture];



    }

点击“takepicture”按钮后,这是代码。

-(IBAction)takePicture:(id)sender {




    cameraTimeInt = timeSlider.value;



    NSTimer *timerStart = [NSTimer scheduledTimerWithTimeInterval:1 target:self selector:@selector(timerTickStart:) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:timerStart forMode:NSDefaultRunLoopMode];



}

我知道代码有点草率,但如果有人有任何想法,那将非常感激:)

我得到的错误是:

CameraTimer [392:907] UIImagePickerController:忽略拍照请求;图像已被捕获或相机尚未准备好。

当我听到两次点击(相机拍照噪音)时,它似乎试图拍摄两张图像。

2 个答案:

答案 0 :(得分:0)

Editted

    UIImageWriteToSavedPhotosAlbum(_imgView.image, nil, nil, nil);

答案 1 :(得分:0)

在您的情况下,NSTimer的时间很早才拍照。所以,将其更改为 7秒 因为拍照可能是在初始化过程中所有组件的时候。

-(IBAction)takePicture:(id)sender {

    cameraTimeInt = timeSlider.value;

    NSTimer *timerStart = [NSTimer scheduledTimerWithTimeInterval:7 target:self selector:@selector(timerTickStart:) userInfo:nil repeats:YES];
    [[NSRunLoop currentRunLoop] addTimer:timerStart forMode:NSDefaultRunLoopMode];

}