我在这里看过这个话题,但没有一个解决方案点击或为我工作。 我有一个 UITableViewController ,(称之为 myUITableViewController ),如果用户选择前三行中的一行,则需要这样做。 strong> myUITableViewController ,它们将被带到 theFirstViewController ,但是如果他们选择上面的任何行三,那么它们将被带到 theSecondViewController 。我使用的故事板似乎不允许单个tableview单元格中的多个segue。 但是,我可以直接从 myUITableViewController 添加多个segue,但后来我正在努力使用正确的segue代码并且找不到合适的解决方案。
答案 0 :(得分:4)
最好的方法是不直接使用IB中的segues,而是使用tableview:didSelectRowAtIndexPath:
并在表中选择一行时从代码中手动调用它们。
您应该将tableview本身的segues设置为目标,而不是表格中的特定元素。
这样的事情:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *identifierOfSegueToCall;
if (indexPath.row < 3) {
identifierOfSegueToCall = @"theFirstViewControllerSegueIdentifier";
} else {
identifierOfSegueToCall = @"theSecondViewControllerSegueIdentifier";
}
[self performSegueWithIdentifier:identifierOfSegueToCall sender:self];
}