Question: OBJECTIVE - C I have a table view which I created programmatically. I have 5 cells in that table view. Every time I click a

OBJECTIVE - C

I have a table view which I created programmatically. I have 5 cells in that table view. Every time I click a cell I want to go to a specific view controller. I used didSelectRowAtIndexPath and it doesn't work. Here is my code below: How to I click a specific table view cell and go to a specific view controller PROGRAMMATICALLY!

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

{

FirstViewController *first = [self.storyboard instantiateViewControllerWithIdentifier:@"firstView"];

SecondViewController *second = [self.storyboard instantiateViewControllerWithIdentifier:@"secondView"];

ThirdViewController *third = [self.storyboard instantiateViewControllerWithIdentifier:@"thirdView"];

FourthViewController *fourth = [self.storyboard instantiateViewControllerWithIdentifier:@"fourthView"];

FifthViewController *fifth = [self.storyboard instantiateViewControllerWithIdentifier:@"fifthView"];

if (tableView==self.MyTableView)

if (indexPath.row==0) [self presentViewController:first animated:YES completion:nil];

else if (indexPath.row==1) [self presentViewController:second animated:YES completion:nil];

else if (indexPath.row==2) [self presentViewController:third animated:YES completion:nil];

else if (indexPath.row==3) [self presentViewController:fourth animated:YES completion:nil];

else if (indexPath.row==4) [self presentViewController:fifth animated:YES completion:nil];

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!