我正在使用UIImagepickerController从相机拍摄照片..我正在使用cameraoverlayview属性在相机视图上使用我自己的视图...我想在用户点击我的自定义视图中的按钮时从相机拍照...我正在使用以下代码
- (void)viewDidLoad {
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:imagePickerController animated:YES];
imagePickerController.showsCameraControls=NO;
imagePickerController.cameraOverlayView = self.customView;
}
- (IBAction) takePicture
{
[imagePickerController takePicture];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
imageView.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[picker dismissModalViewControllerAnimated:YES];
}
- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
[self dismissModalViewControllerAnimated:YES];
}
但是当我运行此代码时,它会给我错误
错误:FigCreateCGImageFromJPEG返回-12905。输入(null)为773625字节。
我也会收到内存使用级别2和级别1
的警告并且imageView中没有显示图像..谁能帮助我,我可能做错了什么? 顺便说一句,我正在使用安装了iOS4.1的iPhone 3G
答案 0 :(得分:1)
UIImagePickerControllerOriginalImage
是一个符号(NSString *
常量),你不能假设它的值。按原样使用,不带引号。除此之外,如果你正确地保留并创建了选择器和图像视图,它应该可以工作。