我试图在不显示图像选择器的情况下拍照。我使用takePicture方法。
这是我的代码:
if ([UIImagePickerController 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];
}
其中imageController为@property(nonatomic,retain) UIImagePickerController* imageController;
我的班级是@interface PhotoVideo : NSObject <UIImagePickerControllerDelegate,UINavigationControllerDelegate>
不幸的是,没有拍摄照片,因为永远不会调用-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
。
感谢您的时间:)
答案 0 :(得分:1)
我的理解是,在使用UIImagePickerController
之前,您仍然需要呈现 -takePicture
作为模态视图控制器或弹出窗口。当您不想使用标准控件时,可以覆盖自定义视图。