After researching about UIImagePickerController, I got this code to select an image from a popover and then display it in myParticularImageView.
This the ViewController.m:
@interface ViewController () {
UIImagePickerController *imagePickerController;
UIPopoverController *popover;
}
@end
- (IBAction)chooseImageButtonPressed:(id)sender {
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
popover = [[UIPopoverController alloc] initWithContentViewController:imagePicker];
[popover setDelegate:self];
[popover presentPopoverFromRect:((UIButton *)sender).frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
//then to dismiss the popover and display pic
-(void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
[[self myParticularImageView] setImage:image];
[popover dismissPopoverAnimated:YES];
}
@end
The problem I have is that when I tap on a pic from the popover nothing happens.
In .h I got:
:UIViewController <UIImagePickerControllerDelegate, UINavigationControllerDelegate, UIPopoverControllerDelegate>
What might cause my problem and how do I solve it?
You are not the image pickers delegate, which is why you are not hitting the delegate method.
Need to add: [imagePicker setDelegate:self];
at some point when creating it.