开发者

Taking a picture without the image picker (modal view)

开发者 https://www.devze.com 2023-03-08 19:04 出处:网络
I\'m trying to take a picture without displaying the image picker. I use the takePicture method. Here is my code:

I'm trying to take a picture without displaying the image picker. I use the takePicture method.

Here is my code:

if ([UIImagePickerControlle开发者_运维百科r isCameraDeviceAvailable:UIImagePickerControllerCameraDeviceFront]) {
    UIImagePickerController *ipc = [[UIImagePickerController alloc] init];
    self.imageController = ipc;
    [ipc release];

    self.imageController.delegate = self;

    self.imageController.sourceType = UIImagePickerControllerSourceTypeCamera;
    self.imageController.cameraDevice = UIImagePickerControllerCameraDeviceFront;
    self.imageController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;

    [self.imageController takePicture];
}

where imageController is @property(nonatomic,retain) UIImagePickerController* imageController;

My class is @interface PhotoVideo : NSObject <UIImagePickerControllerDelegate,UINavigationControllerDelegate>

Unfortunately, the picture isn't taken because -(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info is never called.

Thanks for your time :)


My understanding is that you still need to present the UIImagePickerController, as a modal view controller or a popover, before you can use -takePicture. You can overlay a custom view though when you don't want to use the standard controls.

0

精彩评论

暂无评论...
验证码 换一张
取 消