使用UIImagepickerControllercameraoverlayview拍照?
我正在使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
UIImagePickerControllerOriginalImage
是一个符号(NSString *
常量),您无法假设它的值。按原样使用,不带引号。除此之外,如果您正确保留并创建选择器和图像视图,它应该可以工作。UIImagePickerControllerOriginalImage
is a symbol (anNSString *
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.