UIImagePickerController tutorial? [closed]

心已入冬 提交于 2019-12-18 02:51:27

问题


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?


回答1:


Well if you google something like:

UIImagePickerController and take snapshot put in json and send to server

Will be a bit hard. So, use this tutorial for the UIImagePickerController. By the way, the term for the search was:

UIImagePickerController Tutorial 2012




回答2:


You should check this article from AppCoda Build a Simple iPhone Camera App, very clear and simple :)

Take photo using the native iOS Camera app

- (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

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
    self.imageView.image = chosenImage;

    [picker dismissViewControllerAnimated:YES completion:nil];
}



回答3:


I came across this code AQPhotoPicker. This is quite easy to use with only one call, you will get photo from camera or photoPicker




回答4:


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



来源:https://stackoverflow.com/questions/11328909/uiimagepickercontroller-tutorial

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!