关闭视图控制器 + 表视图控制器 + 主从应用程序

3

我有一个主从应用程序,主从均为UITableViewControllers。在从场景中,我创建了一个按钮并调用它的操作。

- (IBAction)completeTaskButtonPressed:(id)sender {
    [[self delegate] removeCompletedTask:self.indexFromRow controller:self];
}

在Master VC实现中,我有一个方法。
- (void) removeCompletedTask:(NSInteger)index controller:(DetailViewController *) controller {
    [self.dataController.masterTasksList removeObjectAtIndex:index];
    [self.tableView reloadData];
    [self dismissViewControllerAnimated:YES completion:NULL];
}

这些方法必须删除所选行并返回到主视图。问题在于它会删除该行,但不会关闭详细视图。任何帮助都将非常有用。

2个回答

2
听起来你的主从设置涉及到导航控制器。如果您想以与点击“返回”按钮相同的方式关闭详细视图,请使用[self.navigationController popViewControllerAnimated:YES]

1

尝试使用以下代码:

[self dismissModalViewControllerAnimated:YES];
  [self.navigationController popViewControllerAnimated:YES].

你正在弹出视图控制器,这与pushViewController相反:


我尝试将故事板的segue从Push更改为Modal,它可以工作,但我需要使用Push。 - user1248568

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接