Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/107.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 编辑时显示EditViewController,不编辑时显示DetailViewController_Ios_Uitableview_Uistoryboardsegue - Fatal编程技术网

Ios 编辑时显示EditViewController,不编辑时显示DetailViewController

Ios 编辑时显示EditViewController,不编辑时显示DetailViewController,ios,uitableview,uistoryboardsegue,Ios,Uitableview,Uistoryboardsegue,我有一个可编辑的UITableViewController。 我的故事板中有两个片段,从tableView到EditViewController,分别通过modal和Push到DetailViewController 我希望,当tableview正在编辑时,执行到editviewcontroller的segue,而在未编辑时,执行到DetailViewController的segue 我用prepareforsegue方法尝试了不同的方法。然后,我尝试了几次DidSelectRowatineXp

我有一个可编辑的UITableViewController。 我的故事板中有两个片段,从tableView到EditViewController,分别通过modal和Push到DetailViewController

我希望,当tableview正在编辑时,执行到editviewcontroller的segue,而在未编辑时,执行到DetailViewController的segue

我用prepareforsegue方法尝试了不同的方法。然后,我尝试了几次DidSelectRowatineXpath方法

现在,当tableView处于编辑状态时,我触摸一个单元格,detailviewcontroller将按下,在这个单元格的顶部,editviewcontroller将作为模式视图控制器进入

这是我的密码。 你能给我一些提示吗

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
NSLog(@"didSelectRowAtIndexPath %i", indexPath.row);
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
if (tableView.isEditing == FALSE) {
    NSLog(@"isediting");
    [self performSegueWithIdentifier:@"showDetail" sender:cell];
} else {
    [self performSegueWithIdentifier:@"showEditPerson" sender:cell];
}
}
下面是我用prepare for segue方法尝试过的:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
if ([[segue identifier] isEqualToString:@"showDetail"]) {
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    NSDictionary *theChild = [myAppDelegate.myPersonsArray objectAtIndex:indexPath.row];
    [[segue destinationViewController] setDetailItem:theChild];
}
if ([[segue identifier] isEqualToString:@"showEditPerson"]) {
    NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
    NSDictionary *theChild = [myAppDelegate.myPersonsArray objectAtIndex:indexPath.row];
    [[segue destinationViewController] setDetailItem:theChild];
}
}
根据我上面的评论:


除了委托方法之外,您似乎还将原型单元连接到一个segue。修复segue连接后,您应该已全部设置。

您是否仍然可以将segue连接到故事板文件中的原型单元?试着在prepareForSegue中设置断点,看看它是从哪里触发的。嗨,Matt。谢谢。你是对的。我将TableViewCell连接到DetailViewController,而不是将RoottableView连接到DetailViewController。再次感谢!你的,拉斐尔