从编辑附件中查看

时间:2014-01-02 14:31:12

标签: ios uitableview segue

在Xcode中,当我尝试将视图控制器与segue连接时,我可以选择在选择表格单元格时或从单元格的附件中激活segue。如何从单元格的编辑附件创建要触发的segue(在故事板上不可见)?

1 个答案:

答案 0 :(得分:0)

添加accessoryButtonTappedForRowWithIndexPath tableview的委托方法,然后在该委托方法中添加segue代码。

// Tap on row accessory
    - (void) tableView: (UITableView *) tableView accessoryButtonTappedForRowWithIndexPath: (NSIndexPath *) indexPath{
           [self performSegueWithIdentifier:"MyVC" sender:self];
    }

如果你使用的是导航控制器而不是

// Tap on row accessory
    - (void) tableView: (UITableView *) tableView accessoryButtonTappedForRowWithIndexPath: (NSIndexPath *) indexPath{
           ViewController * vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MyVC"];
           [[self navigationController] pushViewController:vc animated:YES];
    }

当您点击附件按钮时调用此方法,但是如果您希望在行上点击该方法而不是使用didSelectRowAtIndexPath方法

相关问题