user2557829
user2557829

Reputation:

TableView cell is not pushing to next view controller

I created the single view application using storyboard.

In storyboard file, i have three view controller

1-navigation controller 2-Recipe Book View Controller 3-View Controller

Prototype cell of the table view of Recipe Book View Controller is connected through push segue to View Controller.Is the problem Recipe Book View Controller does not navigate to View Controller? here is the sample of project for download. https://drive.google.com/open?id=0B5pNDpbvZ8SnLTd1R3NBTE1ReEk

Upvotes: 0

Views: 144

Answers (4)

CodeChanger
CodeChanger

Reputation: 8351

Based on your Source code you have to add some code & classes in your project to achieve your requirement.

1st You have to add RecipeViewController to control your Recipe List and Tableview both.

2nd as You have created this RecipeViewController you need to assign this class to respective ViewController in your storyboard.

3rd Assign Segue from PrototypeCell to ViewController where you need to push.

Hope you can understand whats wrong in your Code.

Upvotes: 0

Neha Gupta
Neha Gupta

Reputation: 539

I just Check your project.

Do following steps:-

  1. In Main.storyboard, click on Push segue to ViewController and add name of identifier

  2. Go to ViewController.m and paste below code

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

Upvotes: 1

Roushan Singh
Roushan Singh

Reputation: 1

Select the segue connecting RecipeBookViewController to ViewController , Then give that segue an identifier, i.e. "ViewControllerSegue".

Implement the delegate method of table view and call the performSegueWithIdentifier method :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

    [self performSegueWithIdentifier:@"ViewControllerSegue" sender:tableView];
}

Upvotes: 0

dahiya_boy
dahiya_boy

Reputation: 9503

Following mistakes are found in your project.

  1. There is no class for Third VC.
  2. PrepareForSegue not implemented.
  3. You wanted to push VC on TableViewCell selection but there you does not implemented didSelect tableview delegate.

Upvotes: 0

Related Questions