I’m trying to use prepareForSegue with an image taken from the camera roll or camera using the UIImagePickerController. This is what I have right now and I don’t know how to finish it, I hope you can help me
ViewController.h
@interface ViewController : UIViewController
<UIImagePickerControllerDelegate, UINavigationControllerDelegate>
-(IBAction)escoger:(id)sender;
-(IBAction)camara:(id)sender;
@property(strong,nonatomic) UIImagePickerController *imagepicker;
@property(strong,nonatomic)IBOutlet UIImageView *image;
Viewcontroller.m
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"escoger"]) {
//UIImagePickerController *intro = [UIImagePickerController ]
imagepicker = [[UIImagePickerController alloc]init];
imagepicker.delegate = self;
imagepicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:imagepicker animated:YES completion:nil];
}}
Well, this is relatively simple if you use the UIImagePickerController with story board. Just create a new viewcontroller in the story board and add a segue. Then set the viewcontroller class to UIImagePickerController in the identity inspector.
Then implement the prepareForSegue: method and set the source to the camera as;
And that works like a charm.