I have didSelectRowAtIndexPath selecting views based on the row number selected, i.e.:
if (indexPath.row == 1) {
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"IdentifierFromStoryboard"];
[self.navigationController pushViewController:detail animated:YES];
}
But as I've now implemented a search bar I'd rather be selecting the views based on the cell.textLabel.text from the cell selected. How would I achieve this?
Edit
You can get the cell by using cellForRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell * cell = [tableView cellForRowAtIndexPath:indexPath];
if ([cell.textLabel.text isEqualToString:@"Click me"]) {
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"IdentifierFromStoryboard"];
[self.navigationController pushViewController:detail animated:YES];
}
else if([cell.textLabel.text isEqualToString:@"Click me instead"]){
DetailViewController *detail = [self.storyboard instantiateViewControllerWithIdentifier:@"IdentifierFromStoryboard"];
[self.navigationController pushViewController:detail animated:YES];
}
}