代码之家  ›  专栏  ›  技术社区  ›  Paweł Zgoda-Ferchmin

UITableView选择节标题

  •  0
  • Paweł Zgoda-Ferchmin  · 技术社区  · 8 年前

    我的行为很奇怪 TableView

    我转身 isUserInteractionEnabled 在我的一个分区标题上,因为我需要 collectionView 在里面。在我做任何事情之前,我注意到当我点击标题视图时(它是 UITableViewCell )它触发了 didSelectRowAt 方法,其中包含该节中第一个单元格的索引(在标题的正下方)。有人知道是什么导致了这种行为以及如何关掉它吗?

    1 回复  |  直到 8 年前
        1
  •  0
  •   Nancy Madan    8 年前

    标题部分是UITableView的一部分。

     func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath){
    }
    
    • 在这个方法中,indexPath返回行和节,indexPath.section ->返回UitableView的节,您已经点击,indexPath.row->返回该节的下半部分,点击。
    • 所以不管你做什么,这个函数都会被调用。你 需要覆盖表视图的姿态以避免出现这种情况。
    推荐文章