I am trying to get the image path & selected image from imagepicker controller.I have used delegate method for getting the path & image but i am always getting null.
Code for showing imagepicker
- (IBAction)choosePicture:(id)sender
{
UIImagePickerController *pickerController = [[UIImagePickerController alloc]
init];
pickerController.delegate = self;
[self presentViewController:pickerController animated:YES completion:nil];
}
Code for delegate
- (void) imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
//You can retrieve the actual UIImage
UIImage *pick_image = [editingInfo valueForKey:UIImagePickerControllerOriginalImage];
NSURL *path = [editingInfo valueForKey:UIImagePickerControllerReferenceURL];
[picker dismissViewControllerAnimated:YES completion:^{
}];
}
protocol code for view controller
#import <UIKit/UIKit.h>
@interface RegisterViewController : UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
@property (weak, nonatomic) IBOutlet UITextField *txt_fname;
@property (weak, nonatomic) IBOutlet UITextField *txt_lname;
@property (weak, nonatomic) IBOutlet UITextField *txt_profession;
@property (weak, nonatomic) IBOutlet UITextField *txt_language;
@property (weak, nonatomic) IBOutlet UITextField *txt_email;
@property (weak, nonatomic) IBOutlet UITextField *txt_password;
@property (weak, nonatomic) IBOutlet UITextField *txt_confirm_password;
@property (weak, nonatomic) IBOutlet UITextField *txt_profile;
@property (weak, nonatomic) IBOutlet UITextField *txt_address;
@end
Maybe it better to use
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info;
like