objective c - Unabe to get image path & image from UIImagePicker in ios using simulator? -
i trying image path & selected image imagepicker controller.i have used delegate method getting path & image getting null.
code showing imagepicker
- (ibaction)choosepicture:(id)sender { uiimagepickercontroller *pickercontroller = [[uiimagepickercontroller alloc] init]; pickercontroller.delegate = self; [self presentviewcontroller:pickercontroller animated:yes completion:nil]; }
code delegate
- (void) imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingimage:(uiimage *)image editinginfo:(nsdictionary *)editinginfo { //you can retrieve actual uiimage uiimage *pick_image = [editinginfo valueforkey:uiimagepickercontrolleroriginalimage]; nsurl *path = [editinginfo valueforkey:uiimagepickercontrollerreferenceurl]; [picker dismissviewcontrolleranimated:yes completion:^{ }]; }
protocol code 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 better use - (void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info;
like
-(void)imagepickercontroller:(uiimagepickercontroller *)picker didfinishpickingmediawithinfo:(nsdictionary *)info { uiimage *originalimage = info[uiimagepickercontrolleroriginalimage]; }
Comments
Post a Comment