I have this code that loads a new UIView (from the storyboard) when a button is clicked. The goPressed function starts when the button is pressed and calls the selectImage function. selectImage opens a UIImagePickerController and allows the user to select a photo. After the user selects the photo, the didFinishPickingMediaWithInfo delegate adds the selected image to the UIImageView.
In 'goPressed', after executing selectImage, it should execute Segue, for example, as // 1. But nothing happens. performSegueWithIdentifier doesn't seem to work. And if I do not call [self selectImage] before calling the performSegueWithIdentifier function, it works. Here is the code:
- (IBAction)goPressed:(id)sender {
[self selectImage];
[self performSegueWithIdentifier:@"lastView" sender:currentSender];
}
-(void)selectImage
{
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
imagePicker.delegate = (id)self;
imagePicker.allowsEditing=NO;
[self presentModalViewController:imagePicker animated:YES];
}
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
UIImage *image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
[[picker presentingViewController] dismissModalViewControllerAnimated:YES];
lePreview.image= image;
}
, , performSegueWithIdentifier ? , , .