Strong84
Strong84

Reputation: 1979

prepareForSegue is not called

  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?

Upvotes: 2

Views: 1398

Answers (1)

Võ Hoàng
Võ Hoàng

Reputation: 9

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];
}

Upvotes: 1

Related Questions