zoukankan      html  css  js  c++  java
  • UITableView-(单元格的自定义方法)

    //contentView

    //行内容
    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
        //从重用队列中取出闲置单元格
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
        //判断cell是否为nil
        if (cell == nil) {
            //创建单元格的时候,要确保重用标示符跟获取闲置单元格的时候一致
            cell = [[UITableViewCell alloc] initWithStyle:indexPath.row % 4 reuseIdentifier:identifier];
            //添加右边的图标
            UIImageView *iconView = [[UIImageView alloc] initWithFrame:CGRectMake(CGRectGetWidth(tableView.frame) - 60 - 20, 10, 60, 60)];
            [cell.contentView addSubview:iconView];
            iconView.tag = 101;
            
            //添加左边的标题Label
            UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(20, 10, CGRectGetWidth(cell.frame) - 100, 60)];
            [cell.contentView addSubview:titleLabel];
            titleLabel.tag = 102;
        }
        
        UIImageView *iconView = [cell.contentView viewWithTag:101];
        UILabel *titleLabel = [cell.contentView viewWithTag:102];
        
        //设置内容
        NSString *iconName = [NSString stringWithFormat:@"icon%ld.jpg",indexPath.row % 6];
        iconView.image = [UIImage imageNamed:iconName];
        
        titleLabel.text = self.datas[indexPath.row];
        
        return cell;
        
    }
  • 相关阅读:
    CouchDB
    在 Fabric 中使用私有数据
    Hyperledger Fabric 踩坑汇总
    书单
    HyperLedger Fabric 资料网址大全
    Hyperledger composer
    Hyperledger Fabric
    [转]以太坊智能合约编程之菜鸟教程
    [转]Ethereum-智能合约最佳实践
    [转]工作量证明(PoW)权益证明(PoS)和委任权益证明(DPoS)区别
  • 原文地址:https://www.cnblogs.com/longiang7510/p/5379183.html
Copyright © 2011-2022 走看看