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

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

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

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


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

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

然后在cellForRowAtIndexPath:里赋值


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


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


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


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

【热门文章】
【热门文章】