0
votes

I have a custom UIScrollView class that implements the touchesEnded method. My project has a storyboard, and I am trying to call the performSeguewithIdentifier on the viewcontroller but when I call the method changePhoto it gives me the error below. I have verified that my segue is labeled correctly, it is not misspelled. It looks like when I am creating the new instance of the PhotoViewController it doesnt create any of the storyboard and/or the segues. What can I do to call to get the segue to work properly from my UIScrollView?

CustomUIScrollView.m

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{

    UITouch *touch = [touches anyObject];

    if ([[touch view] isKindOfClass:[UIImageView class]]) {
        UIView *imageView = [touch view];
        NSInteger tag = imageView.tag;
        NSLog(@"Tag: %d", tag);
        PhotoViewController *vc = [[PhotoViewController alloc]init];
        [vc changePhoto:1];
    }
}

PhotoViewController.m

-(void)changePhoto:(int)spaceId {
    [self performSegueWithIdentifier: @"photoSegue" sender: self];
}

Error:

2012-10-09 10:28:38.765 Spaces[82945:11303] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'photoSegue''

1

1 Answers

1
votes

Try initializing you view controller with this

PhotoViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@"myIdentifier"]

Be sure to set the identifier of the according view controller in the interface builder.