为不同的列分配不同的按钮,具有不同的行为

Assign different buttons, with different behaviours for different columns

在我的项目中,我有 UITableView。 我需要为不同的列分配不同的按钮,具有不同的行为。

问题:

  1. 为按钮设置不同行为和操作的正确方法在哪里?它在 (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 中吗?
  2. 将具有不同行为的不同按钮分配给不同列的正确方法是什么?我在想 [_buttonArray objectAtIndex:indexPath.section]; 这样对吗?

示例:第 1 列 - 按钮 A -> 按下按钮 A 后更改 button.title 和大小并执行 X。

如果您希望用户能够点击整个单元格并触发按钮操作,您应该对按钮行为使用以下方法。如果没有,您应该在自定义单元格 class 中使用操作委托。如果您在设置协议文件和/或委托方法方面需要帮助,请告诉我。

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

}