2
votes
  1. I create a scrollView using storyboard.
  2. I programticaly created 10 myController(which are UITableViewControllers) inside the scrollViewController, So I can use panGesture to switch between tables. and it's working fine.
  3. I created a tableViewController using storyboard, set myController to be the corresponding view controller.
  4. Embedded the tableViewController in navigation controller.
  5. Control drag from table cell to a new view controller to create a push segue.
  6. Setup segue.

when running the app, prepareForSegue: is never called.

Edit: After noticing this issue, I did the follow thing but with no luck.

I also set the segue identifier in storyboard correctly. and add the following code:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"segueIdentifier" sender:self];
}

but when I tap any table cell on screen, program will crash with following error:

* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver () has no segue with identifier 'segueIdentifier'' * First throw call stack:

Why is that?

1
The error is self-explanatory, isn't it? The segue you're trying to perform does not exist in your storyboard. You probably forgot to name it or there is a typo in the identifier. - Pier-Luc Gendreau
I did add segue identifier by clicking the segue icon and put text in identifier box. is that what you talked about? - Strong84
Yes, although I'm pretty sure it has to do with your programmatically created controllers. Segues only work in tandem with storyboards, but you could try creating a manual segue. See: stackoverflow.com/questions/9674685/… - Pier-Luc Gendreau
I've checked the identifier again, no problem at all, exactly the same. - Strong84
Does it match segueIdentifier? The two have to be the same. Also make sure that you hit enter (or return) after typing otherwise it won't set. - CaptJak

1 Answers

1
votes

I think your problem here "5. Control drag from table cell to a new view controller to create a push segue."

Try drag from your view controller (not your table cell) to new view controller and create push segue, then try with

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"segueIdentifier" sender:self];
}