使用UIImagepickerControllercameraoverlayview拍照?

发布于 2024-10-01 15:58:55 字数 1277 浏览 0 评论 0原文

我正在使用 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。输入(空)为 773625 字节。

我还收到内存使用级别 2 和级别 1 的警告

,并且 imageView 中没有显示任何图像。任何人都可以帮助我,我可能做错了什么? 顺便说一句,我使用的是安装了 iOS4.1 的 iPhone 3G

i am using UIImagepickerController to take pictures from camera..i am using my own view over the camera view by using the cameraoverlayview property...i want to take a picture from camera when user clicks on a button in my custom view...i am using the following code

 - (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];
}

but when i run this code it gives me error

ERROR: FigCreateCGImageFromJPEG returned -12905. Input (null) was 773625 bytes.

and i also get warnings for memory use level 2 and then level 1

and no image is displayed in the imageView.. can anyone help me what i might be doing wrong??
btw i am using iPhone 3G with iOS4.1 installed on it

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

好听的两个字的网名 2024-10-08 15:58:55

UIImagePickerControllerOriginalImage 是一个符号(NSString * 常量),您无法假设它的值。按原样使用,不带引号。除此之外,如果您正确保留并创建选择器和图像视图,它应该可以工作。

UIImagePickerControllerOriginalImage is a symbol (an NSString * constant) and you can't assume its value. Use as is, without quotes. Other than that, if you properly retain and create both the picker and the image view, it should work.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文