This is my situation. I’ve two table views. After searching on working with two tableviews in one view, i came to the solution to make 2 extra controllers. Namely tbl1DatasourceDelegate and tbl2DatasourceDelegate. Now when I push on a cell, it should segue to another viewController. I have this code in my tbl1DatasourceDelegate.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
PlayerNews *news = [_tableSource objectAtIndex:indexPath.row];
PlayerDetailController *detail =[[PlayerDetailController alloc]init];
[detail setNewsItem:news];
}
So when I select a Cell I make a playerNewsObject and send it back to my Controller with the 2 tableviews in it. When I got back in my controller with the two tableviews in it. (controller where I segue-ing from) I execute the function setNewsItem Here you see the code.
-(void)setNewsItem:(PlayerNews *)newsItem{
if(![_newsItem isEqual:newsItem]){
_newsItem = newsItem;
}
NSLog(@"Player detail controller newsItem object: %@", _newsItem);
[self performSegueWithIdentifier:@"PlayerDetailNews" sender:tblNews];
}
This code is executed because my log shows the newsItem I pushed on the tableview. But It won’t segue to it. I am using the following prepareForSegue.
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSLog(@"comes in this segue");
// ask NSFRC for the NSMO at the row in question
if ([segue.identifier isEqualToString:@"PlayerDetailNews"]) {
[segue.destinationViewController setImageURL:[NSURL URLWithString:_newsItem.image]];
[segue.destinationViewController setNewsTitle:_newsItem.title];
[segue.destinationViewController setNewsDescription:_newsItem.content];
[segue.destinationViewController setNewsCopy:_newsItem.image_copyright];
[segue.destinationViewController setNewsUrl:_newsItem.url];
[segue.destinationViewController setNewsShortDescription:_newsItem.summary];
}
}
It does not come in this method because it does not print the log. It crashes with the following error.
** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Receiver (<tblPlayerNewsDatasourceDelagete: 0x1e5e44c0>) has no segue with identifier 'showPlayerDetailNews''
Can anybody help me?
Thank you
Two reasons for not being able to launch a segue:
1) Misspelling of the segue identifier. Double check the identifier used in the Storyboard and your code. Side note: identifiers don’t have to be unique in the storyboard, just for each viewcontroller. Let’s say you have viewcontroller A with segue to B and a viewcontroller C with a segue to B, they are allowed to have the same identifiers.
2) Trying to launch a segue which is not connected to the UIViewController you’re trying to launch it from. So for example: you have segue ‘segueA’ which connects viewcontroller A to B. In this case, the only place where you are able to use
[self performSegueWithIdentifier:@"segueA" sender:nil]is A.