登录

iOS collectionview 里有多个section 如何知道点击的是哪个section哪个row里的btn?

collectionview 里有多个section 多个cell 如何知道点击的是哪个section里的哪个row里的button???????

想选择button改变选中的button的颜色

# iOS
高洛峰 高洛峰 2386 天前 904 次浏览

全部回复(5) 我要回复

  • 阿神

    阿神2017-04-17 17:35:09

    最简单的方法根据button的tag直接改button颜色就好了,不用找section,row.
    UIButton btn = (UIButton )[self.view viewWithTag:564684];

    回复
    0
  • 怪我咯

    怪我咯2017-04-17 17:35:09

    个人觉得用block是最干净优雅的

    回复
    0
  • PHP中文网

    PHP中文网2017-04-17 17:35:09

    只是想改变选中button的颜色的话,直接修改sender不就好了么。。

    回复
    0
  • PHPz

    PHPz2017-04-17 17:35:09

    给每个button加tag,获取点击事件的sender.tag

    回复
    0
  • 巴扎黑

    巴扎黑2017-04-17 17:35:09

    自定义一个UIButton,然后给button添加属性 比如:

    @property (nonatomic) NSInteger section; 
    @property (nonatomic) NSInteger row;
    

    然后在cellForRowAtIndexPath:里赋值

    回复
    0
  • 取消 回复 发送