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;
    }


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

  • 相关阅读:
    MongoDB 查询$关键字 $in $or $all
    MongoDB limit 选取 skip跳过 sort排序 方法
    POJ 1700
    POJ 1666
    POJ 1701
    POJ 1674
    POJ 1664
    POJ 1665
    POJ 1658
    POJ 1656
  • 原文地址:https://www.cnblogs.com/bhlsheji/p/4650180.html
Copyright © 2011-2022 走看看