zoukankan      html  css  js  c++  java
  • 自己的自定义单元格(IOS)

    定义自己的单位格有三种方法

    - 代码

    - xib

    - storyboard(推荐)

    操作方法故事板

    1、在TableView财产Prototype Cells至1。莫感觉1;

    2、须要创建自己定义的单元格类;

    3、设定Table View Cell的Class为自己定义类;


    自己定义类:(并不难)

    #import "CustomCell.h"
    
    @implementation CustomCell
    
    - (void)awakeFromNib {
        // Initialization code
    }
    
    - (void)setSelected:(BOOL)selected animated:(BOOL)animated {
        [super setSelected:selected animated:animated];
    
        // Configure the view for the selected state
    }
    
    @end
    




    必须实现的数据源协议的方法:

    #pragma mark --UITableViewDataSource 协议方法
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return [self.listTeams count];
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        // 定义可重用单元格对象
        static NSString *cellIdentifier = @"Cell";
        CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
        
        NSUInteger row = [indexPath row];
        NSDictionary *rowDict = [self.listTeams objectAtIndex:row];
        cell.name.text = [rowDict objectForKey:@"name"];
     
        NSString *imagePath = [rowDict objectForKey:@"image"];
        imagePath = [imagePath stringByAppendingString:@".png"];
        cell.image.image = [UIImage imageNamed:imagePath];
        
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        return cell;
    }


    版权声明:本文博客原创文章,博客,未经同意,不得转载。

  • 相关阅读:
    性能02篇-性能测试工具介绍
    网关协议:CGI和WSGI
    Spring Cloud与微服务构建:Spring Cloud简介
    前端基础:HTTP 状态码详解
    Spring Cloud与微服务构建:微服务简介
    Redis 基础:Redis 事件处理
    Redis 基础:Redis 数据类型
    Redis 基础:Redis 配置
    Django 2.0 学习(22):Django CSRF
    Django 2.0 学习(21):Django Session
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4650180.html
Copyright © 2011-2022 走看看