UIImagePickerController tutorial? [closed]

2020-02-09 04:23发布

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?

4条回答
我想做一个坏孩纸
2楼-- · 2020-02-09 04:31

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楼-- · 2020-02-09 04:35

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

查看更多
放我归山
4楼-- · 2020-02-09 04:41

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

查看更多
女痞
5楼-- · 2020-02-09 04:49

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

查看更多
登录 后发表回答