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.
精彩评论