ios UIImagePickerController 教程?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11328909/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
UIImagePickerController tutorial?
提问by Rui Peres
I am currently developing an application and I need to be able when pressing a button to open the camera and take a snapshot that I will attach to a .json file and send to my server.
I am searching on google and StackOverflow for the last couple of hours but all the tutorials seem very old (08'-09') or not match my needs. I know that all the work is done with UIImagePickerController
class but I would like to have a working example. Does anyone know a good tutorial to get started for something like this?
我目前正在开发一个应用程序,我需要能够按下按钮打开相机并拍摄我将附加到 .json 文件并发送到我的服务器的快照。我在过去几个小时内在 google 和 StackOverflow 上搜索,但所有教程似乎都很旧(08'-09')或不符合我的需求。我知道所有的工作都是在UIImagePickerController
课堂上完成的,但我想要一个有效的例子。有没有人知道一个很好的教程来开始这样的事情?
回答by onmyway133
You should check this article from AppCoda Build a Simple iPhone Camera App, very clear and simple :)
您应该查看 AppCoda Build a Simple iPhone Camera App 中的这篇文章,非常清晰和简单:)
Take photo using the native iOS Camera app
使用原生 iOS 相机应用拍照
- (IBAction)takePhoto:(UIButton *)sender {
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:nil];
}
Read the captured photo (you have to implement UIImagePickerControllerDelegate
读取捕获的照片(您必须执行 UIImagePickerControllerDelegate
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.imageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:nil];
}
回答by Rui Peres
Well if you google something like:
好吧,如果你用谷歌搜索:
UIImagePickerController and take snapshot put in json and send to server
UIImagePickerController 并将快照放入 json 并发送到服务器
Will be a bit hard. So, use thistutorial for the UIImagePickerController
. By the way, the term for the search was:
会有点难。因此,将本教程用于UIImagePickerController
. 顺便说一下,搜索的术语是:
UIImagePickerController Tutorial 2012
UIImagePickerController 教程 2012
回答by aqavi_paracha
I came across this code AQPhotoPicker. This is quite easy to use with only one call, you will get photo from camera or photoPicker
我遇到了这个代码AQPhotoPicker。这很容易使用,只需一个电话,您将从相机或 photoPicker 获取照片
回答by Denis Kutlubaev
Try this. It's very simple, you just need to set delegate for a controller and call it. Google will help you, there are plenty of resources and working examples. For instance, sample code from Apple
试试这个。很简单,你只需要为控制器设置委托并调用它。谷歌会帮助你,有很多资源和工作示例。例如,来自 Apple 的示例代码