How to pick image from gallery and that image put in to our application
objective-c
Solution
you can use this code
- (IBAction)addImage:(id)sender {
UIActionSheet *action = [[[UIActionSheet alloc] initWithTitle:@"Select image from"
delegate:self
cancelButtonTitle:@"Cancel"
destructiveButtonTitle:nil
otherButtonTitles:@"From library",@"From camera", nil] autorelease];
[action showInView:self.view];
}
#pragma mark - ActionSheet delegates
- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
if( buttonIndex == 0 ) {
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
UIImagePickerController *pickerView =[[UIImagePickerController alloc]init];
pickerView.allowsEditing = YES;
pickerView.delegate = self;
pickerView.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController:pickerView animated:YES completion:nil];
}
}else if( buttonIndex == 1 ) {
UIImagePickerController *pickerView = [[UIImagePickerController alloc] init];
pickerView.allowsEditing = YES;
pickerView.delegate = self;
[pickerView setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
[self presentViewController:pickerView animated:YES completion:nil];
}
}
#pragma mark - PickerDelegates
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
[self dismissViewControllerAnimated:YES completion:nil];
UIImage * img = [info valueForKey:UIImagePickerControllerEditedImage];
myImageView.image = img;
}
Problem
I have beginner of iPhone any source code and suggestion related display image in to our apps and pick the photo from gallery