iOS 在cell上面查找你设置的控件

来源:互联网 发布:pano2vr.js 域名限制 编辑:程序博客网 时间:2024/06/05 02:52

一般需要设置cell 上面的控件,都要用到下面的方法

//设置单选与点击事件关联

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    for (UIView *viewin cell.subviews){

        if (view.tag == 1) {

            ZYRadioButton *onceButton = (ZYRadioButton *)view;

            onceButton.selected = YES;

        }

    }

    

}

当然在初始话的时候,已经把自定义的特许按钮ZYRadioButton *onceButton,的tag设置为1,所以在cell.subviews的子视图中可以按照tag值找到onceButton。而UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];这句话是可以在点击事件中获取点击的cell。
0 0
原创粉丝点击