Reputation: 89
I would like to use the default camera view that you can use when opening the camera app and being able to select photos. After that, I would like to make a request and send the photo using an API. Would this be possible?
Upvotes: 1
Views: 657
Reputation: 877
There are two different controllers, one for the camera and the other is photos.
For the camera, you can use: UIImagePickerController
example source code for launching the camera from your view controller:
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[presentingViewController presentViewController:_picker animated:YES completion:nil];
//In delegate method you will receive image
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
//process your image here and do whatever you want to do
}
The same controller can be used for selecting images too (by specifying picker.sourceType value as UIImagePickerControllerSourceTypePhotoLibrary), from iOS 14 new API is introduced for supporting multiple image selection: PHImagePickerViewController
.
Check this link provides sample code from apple and WWDC talk about this new API:
https://developer.apple.com/documentation/photokit/selecting_photos_and_videos_in_ios
Upvotes: 1