iOS 自定义cell

1、新建类 继承uitablecell类

2、新建interface empty视图

3、拖动一个cell控件到窗体  拖动相关的布局控件到cell上

4、完成重写 .m文件的set方法(调用的时候不能直接操作cell上的控件,而是要操作cell控制器类的set方法)

5、引入自定义类的.h头文件 #import “aaa.h”

5、在主视图上 tableview中添加代码

static NSString *CellIdentifier = @"listCustomCell";
    listCustomCell *cell = (listCustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        NSArray *array = [[NSBundle mainBundle] loadNibNamed:@"listCustomCell" owner:self options:nil];
        cell = [array objectAtIndex:0];
        cell.backgroundView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"list_back.png"]];
    }
    // NSLog(@"号码%@",[_key objectAtIndex:indexPath.row]);
    //NSLog(@"shu%d",indexPath.row);
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    cell.haoma=[_key objectAtIndex:indexPath.row];
    NSLog(@"%d",indexPath.row);


名称是类名  listcustomCell

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值