0

I have a tableview that is within a container view. When the user selects any of the rows, a method is called in the parent controller, which tells the parent controller to perform a segue. However, I am unable to figure out why it doesn't work. The code gets called from the didSelectRow -function in the tableView. The method does perform, but it gives me an error about no segue with that identifier.

However, when I call the method(listJobsOfSite) from within the parent view controller it works.

(tableview)

   -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self.jobVC listJobsOfSite:@"locPwn"];
}

parent view controller

-(void)listJobsOfSite:(NSString *)site
{
    [self performSegueWithIdentifier:@"JobSegue2" sender:nil];
}

EDIT: The segue is between view controller 1, and view controller 2. view controller 1 holds a container view, which again holds a table view controller. This tableview controller should tell view controller 1 to segue into view controller 2.

EDIT 2: screenshot http://tinypic.com/r/30x7dr9/8

Runar
  • 245
  • 3
  • 17
  • Between what and what exactly is the `segue`? I guess it's between the parent and the next ViewController, whereas you try do to it throught the child controller and the next ViewController. I'll tell the parent that it needs to perform the segue. – Larme Apr 06 '14 at 16:35
  • The segue is between view controller 1, and view controller 2. view controller one holds a container view, which again holds a table view controller. This tableview controller should tell view controller 1 to segue into view controller 2. – Runar Apr 06 '14 at 17:42

1 Answers1

2
  1. You don't call classes. The word you are looking for is "method." You call your listJobsOfSite method that is in your parent view controller class .

  2. Have you made sure you have given the segue an identifier? In your Storyboard you should click on the segue, inspect it, and enter "JobSegue2" in the field marked "Identifier."

  3. If you have done step 2, do you need a container view? What are you trying to accomplish with the Container View + TableView? It sounds like your design would make more sense without the container view and the TableView as a property of View Controller 1.

If your heart is set on using the container view, in your Storyboard try to Control + Drag from your TableView cell to your View Controller 2. Name that segue "JobSegue2." Then you don't need to call any methods in your didSelectRow method. You also don't need a storyboard segue from View Controller 1 to 2. It seems like this question has the behavior you want (the question, not the answer! He is having the opposite problem you are).

Edit: Just noticed you have a Navigation Controller within your container view, so my suggestion above will likely push View Controller 2 within the container view. I'm totally confused by what you're trying to do.

Community
  • 1
  • 1
CocoaDog
  • 305
  • 1
  • 11
  • 1. Yes, thanks for clearing that up. I'll edit my post. 2- Yes, the identifier is there. Calling the method from within the parent view controller works, but not calling it from the child table view controller. – Runar Apr 06 '14 at 17:39
  • Is there any reason you have the segue code in the parent view controller? I don't really understand the way you've designed this or why you need to call the segue from the parent. It seems like you want to segue from the TableView to another view, so the segue method should be in your TableViewController. – CocoaDog Apr 06 '14 at 17:45
  • I did try that initially. The following crashes with the same error. I know the segue is there. - (void)viewDidLoad{ self.jobVC = [[JobViewController alloc] init]; } -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath [self.jobVC performSegueWithIdentifier:@"JobSegue2" sender:Nil]; } – Runar Apr 06 '14 at 18:13