Open a camera and camera roll from your application in iOS
If you want to open the camera from your application. You can open using UIImagePickerController. If you click the image from the camera :-
1 2 3 4 5 |
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.allowsEditing = YES; picker.sourceType = UIImagePickerControllerSourceTypeCamera; [self presentViewController:picker animated:YES completion:NULL]; |
If you want to open the camera roll :-
1 2 3 4 5 6 |
UIImagePickerController *picker = [[UIImagePickerController alloc] init]; picker.delegate = self; picker.allowsEditing = YES; picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary ; [self presentViewController:picker animated:YES completion:NULL]; |
After that you will get the information of your image from the UIImagePickerController delegate method.
1 2 3 4 5 6 7 |
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info { UIImage *chosenImage = info[UIImagePickerControllerEditedImage]; NSData *imageData = UIImageJPEGRepresentation(chosenImage, 1.0); [picker dismissViewControllerAnimated:YES completion:NULL]; } |