zoukankan      html  css  js  c++  java
  • UITableViewCell 上的按钮点击事件

         

        以前做tableViewCell的button点击事件,总是建立一个全局的可变数组,把data放在数组里,点击获取button的tag值,根据tag从数组了里取data。

           其实,如果section只有一个的时候,可以直接获取点击的路径来点击的cell。

       1 NSIndexPath *selectIndexPath = [NSIndexPath indexPathForRow:tag_value inSection:0];//因为table只有一个section

       2 UITableViewCell * selectCell = (UITableViewCell *)[self.table cellForRowAtIndexPath:selectIndexPath]; 

          如果有多个section的时候怎么办呢?

          我想到一个比较笨的方法, section i ,row j :  button的tag =   i*1000  + j ;

         1 NSIndexPath *selectIndexPath = [NSIndexPath indexPathForRow:(tag_value%1000) inSection:(tag_value/1000)];   

       

            如果您想到更好的方法,欢迎留言讨论~

  • 相关阅读:
    docker swarm 集群搭建和臫servoce对服务扩容
    docker 可视化 portainer
    docker Compose
    hadoop2 安装
    y的最大值最小值切割
    滑块图片拼接
    ast 对象还原
    babel/types is判断
    t.isLiteral()
    杂题集合
  • 原文地址:https://www.cnblogs.com/A--G/p/4843398.html
Copyright © 2011-2022 走看看