Can anyone help me to implement a functionality --> Take photo or Choose from gallery options, when camera option is selected in app.
Asked
Active
Viewed 1.2k times
0
-
http://www.appcoda.com/ios-programming-camera-iphone-app/ – Bhavin Bhadani Apr 18 '16 at 06:13
-
you need code in objective c or swift ? – Birendra Apr 18 '16 at 06:13
-
What you have tried/searched/googled so far? – Ashish Kakkad Apr 18 '16 at 06:17
-
http://stackoverflow.com/questions/6373730/how-to-add-image-from-photo-library-or-camera-to-my-ipad-application – Bhavin Bhadani Apr 18 '16 at 06:18
-
yes i need to code in objective c. I have tried by implementing a view with two button to take pic and choose from gallery. Is there any other methods to bring those buttons when the camera options is selected in app. – ragul ml Apr 18 '16 at 06:26
-
I have done this. I want to show the buttons(take picture or use gallery) when camera option is selected. Can u please help me for that – ragul ml Apr 18 '16 at 07:20
1 Answers
17
// For taking image by camera
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:picker animated:YES completion:nil];
// For picking image from gallery
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:nil];
// for output image
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
// output image
UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
self.profileImageView.image = chosenImage;
[picker dismissViewControllerAnimated:YES completion:nil];
}
Don't forget to add UIImagePickerControllerDelegate and UINavigationControllerDelegate.

Code cracker
- 3,105
- 6
- 37
- 67
-
I have done this. I want to show the buttons(take picture or use gallery) when camera option is selected. Can u please help me for that. – ragul ml Apr 18 '16 at 07:18
-
1you can use `UIActionsheet` to do that. on your button tap open actionsheet with two options camara or photo library. refer this link http://stackoverflow.com/questions/17223210/creating-uiactionsheet to learn how to use action sheet. open camara on camara button of actionsheet and same for photo library – Ketan Parmar Apr 18 '16 at 07:29
-
you seems to be new iOS developer. just you need to customize by yourself. discuss with your team for that UI. No one can help for this kind of this kind of questions. – Code cracker Apr 18 '16 at 07:44