UITableViewCell 上的按钮点击事件

     

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

       其实,若是section只有一个的时候,能够直接获取点击的路径来点击的cell。spa

 

   1 NSIndexPath *selectIndexPath = [NSIndexPath indexPathForRow:tag_value inSection:0];//由于table只有一个sectioncode

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

 

      若是有多个section的时候怎么办呢?事件

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

 

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

   

        若是您想到更好的方法,欢迎留言讨论~class

相关文章
相关标签/搜索