UITableView Cell的属性方法



*************************常用cell属性*****************************
**************************************************
//复用编辑按钮和完成按钮

- (void)btnClick:(UIBarButtonItem *)btn

{

    //设置表视图是否进入编辑模式

    [_tableView setEditing:![_tableView isEditing] animated:YES];

    //将导航烂右按钮设置为完成

    self.navigationItem.rightBarButtonItem = [_tableView isEditing] ? _finishBtn : _editBtn;

}

***************************************************

        //设置cell上面显示的文本信息

        //参数1:indexPath.section:指定的分组

        //参数2:indexPath.row:指定的行

        tc.textLabel.text = [NSString stringWithFormat:@"%li组,%li行",indexPath.section,indexPath.row];


    UILabel *label = [[UILabel alloc]init];

    label.frame = CGRectMake(200, 5, 100, 30);

    label.text = @"测试label";

    label.tag = 100;

    //加入子视图的时候需要加到cellcontentView

       [tc.contentView addSubview:label];


        //设置cell的详细信息(需要设置风格才能显示详情信息)

        //UITableViewCellStyleDefault  --默认有图片文字

        //UITableViewCellStyleValue1,  --有图片文字详情

        //UITableViewCellStyleValue2,  --有文字详情

        // UITableViewCellStyleSubtitle--有图片文字详情

        tc.detailTextLabel.text = @"详情介绍”;

        //设置cell的图标

        tc.imageView.image = [UIImage imageNamed:@"tab_c3"];

    

    //设置cell附属视图的类型

    //UITableViewCellAccessoryNone,

    //UITableViewCellAccessoryDisclosureIndicator,

    //UITableViewCellAccessoryDetailDisclosureButton,

    //UITableViewCellAccessoryCheckmark,

    //UITableViewCellAccessoryDetailButton

    tc.accessoryType = UITableViewCellAccessoryCheckmark;

    //可以自定义附属视图

    tc.accessoryType = [UIButton buttonWithType:UIButtonTypeContactAdd];

    

    UIView *view = [[UIView alloc]init];

    view.backgroundColor = [UIColor redColor];

    //设置选中的cell的背景视图

    tc.selectedBackgroundView = view;

    //设置cell的背景图片

    tc.backgroundView = [UIImage imageNamed:@"111.jpg”];



*************************当点击cell时调用这个方法*************************


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


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值