Reputation: 953
I am trying to capture an image and save it in the imageview. Below is the code.
- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
NSLog(@"Hello");
[picker dismissModalViewControllerAnimated:YES];
[_Image setImage:image];
}
- (IBAction)Capture:(UIButton *)sender {
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController: cameraUI animated: YES completion:nil];
}
The problem is imagepickercontroller is not called at all!! My .h declaration is
@interface AikyaViewController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
I can get the camera to capture the image, but the image is not saving in my imageview. Infact it is not entering that function itself since its not NSlogging.
Should i have to link anything in the storyboard or any delegates initialisation am i missing?? Plz guide the same.
Upvotes: 1
Views: 788
Reputation: 6079
imagePickerController:didFinishPickingImage:editingInfo
: is deprecated
change that method with:
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSLog(@"done");
[picker dismissViewControllerAnimated:YES completion:Nil];
[image setImage:[info objectForKey:@"UIImagePickerControllerEditedImage"]];
}
and try to change:
- (IBAction)Capture:(UIButton *)sender {
UIImagePickerController *cameraUI = [[UIImagePickerController alloc] init];
[cameraUI setDelegate:self];
[cameraUI setAllowsEditing:YES];
cameraUI.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentViewController: cameraUI animated: YES completion:nil];
}
Upvotes: 2