代码之家  ›  专栏  ›  技术社区  ›  Designer023

单元视图公开按钮及相关方法

  •  5
  • Designer023  · 技术社区  · 15 年前

    我一直在和一个手机按钮斗争。。。首先,它是说,它是折旧,因为我正在使用:

    -(UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath {
     return UITableViewCellAccessoryDetailDisclosureButton;
    }
    

    因此,我对此进行了注释,并使用以下方法将披露添加到configureCell中的单元格中:

    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    cell.editingAccessoryType = UITableViewCellAccessoryNone;
    

    但是现在我的“披露”按钮什么也不做。我需要添加什么才能让“披露”按钮正常工作。我在google上找到的都是其他被贬低的方法。任何帮助或指点将不胜感激。

    3 回复  |  直到 11 年前
        1
  •  14
  •   James Huddleston    15 年前

    如果您真的想要一个详细信息披露按钮,请确保您正在设置您的手机配件类型为 UITableViewCellAccessoryDetailDisclosureButton . (您的示例代码显示 UITableViewCellAccessoryDisclosureIndicator )在表视图代理的 tableView:accessoryButtonTappedForRowWithIndexPath: 方法。您可以在表视图代理中处理行选择(无论附件视图是什么) tableView:didSelectRowAtIndexPath:

        2
  •  3
  •   Jorge    15 年前

    在表视图委托中使用此方法

        - (void)tableView:(UITableView *)tableView accessoryButtonTappedForRowWithIndexPath:(NSIndexPath *)indexPath
    
        3
  •  0
  •   Ketan P    9 年前

    swift3.0中的委托方法

    func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
    
    }
    

    cell.accessoryType = .detailDisclosureButton
    cell.accessoryType = .detailButton
    
    推荐文章