【发布时间】:2013-03-14 14:39:05
【问题描述】:
有没有办法在不通过 Apple 控件的情况下在 iPad 上拍照?我见过很多这样的应用程序,
例如,当您在 iPhone 中添加新联系人时,在左上角显示add photo,当我们点击它时,相机会打开并拍照并保存到add photo..
我想实现相同的功能.. 可以在 iPad 上实现吗?
【问题讨论】:
标签: iphone ios ipad uiimageview camera
有没有办法在不通过 Apple 控件的情况下在 iPad 上拍照?我见过很多这样的应用程序,
例如,当您在 iPhone 中添加新联系人时,在左上角显示add photo,当我们点击它时,相机会打开并拍照并保存到add photo..
我想实现相同的功能.. 可以在 iPad 上实现吗?
【问题讨论】:
标签: iphone ios ipad uiimageview camera
您需要做的是,首先添加一个按钮,标题为“添加照片”或自定义图像。
然后点击按钮添加以下代码:
if (([UIImagePickerController isSourceTypeAvailable:
UIImagePickerControllerSourceTypeCamera] == NO)
return NO;
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController: cameraUI animated: YES completion:nil];
它将打开相机,然后单击图像,然后点击“使用”,您必须实现 UIImagePickerControllerDelegate 方法 imagePickerController:didFinishPickingMediaWithInfo: 然后将 UIImage 存储到您想要的任何位置,使用任何你想要的文件名,使用 NSFileManager 方法。
【讨论】:
imageview的图像这是我的代码- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { [picker dismissModalViewControllerAnimated:YES]; UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage]; [imgVw setImage:image]; imgVw.contentMode = UIViewContentModeScaleAspectFill; }
使用图像选择器控制器,您可以使用您在问题中描述的相同功能。
为此,您需要将图片转换为图像数据并在uiimageview中显示
你可以参考这个:UIImageView Class Reference
这也将为您提供示例。
Taking a picture from the camera and show it in a UIImageView的这个答案将为您提供正确的答案..
享受编程!
【讨论】: