使用多个cell的表格注册多个

本文档介绍了如何在表格中使用多个自定义Cell进行注册和管理,详细讲解了自定义Cell的创建过程以及在表格中正确显示的方法,旨在帮助开发者实现更灵活的表格展示效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell;
    switch (indexPath.section)
    {
        case 0:{
            TwoTableViewCell   *Tcell = [tableView dequeueReusableCellWithIdentifier:@"two"];
            if (!Tcell) {
                Tcell = [[TwoTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"two"];
            }
            Tcell.imageView.image = [UIImage imageNamed:@"2"];
            Tcell.textLabel.text = @"创业黑马董事长:区块链是机会,但不是每个人的机会";
            return Tcell;
        }
            break;
        case 1:{
            NSArray *imgarr = @[@"3",@"4",@"5"];
            NSArray *textarr = @[@"区块链能否打破垄断,颠覆传统的商业模式?",@"区块链走进联合国,首届全球区块链大会",@"IDC Wallet全球首创跨链多笔山对(Swapit)服务"];
            OneTableViewCell   *Ocell = [tableView dequeueReusableCellWithIdentifier:@"one"];
            if (!Ocell) {
                Ocell = [[OneTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"one"];
            }
            Ocell.imgimg.image = [UIImage imageNamed:imgarr[indexPath.row]];
            Ocell.lab.text = textarr[indexPath.row];
            return Ocell;
        }
            break;
        default:
        {
//            cell = [tableView d
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值