zoukankan      html  css  js  c++  java
  • UITableVIewCell的设置(附标题/高度/右边的标识)

    方法:

    -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{

        //创建cell

        UITableViewCell *cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nil];

        //设置cell的图片

        NSString *imageName = [NSString stringWithFormat:@"00%ld.png",indexPath.row + 1];

        cell.imageView.image = [UIImage imageNamed:imageName];

        //设置cell的主标题

        NSString * text = [NSString stringWithFormat:@"产品-%ld",indexPath.row + 1];

        cell.textLabel.text = text;

        //设置cell的附标题, 它的显示跟创建cell时的style有关

       // style = UITableViewCellStyleDefault :附标题不显示,图片显示

       // style = UITableViewCellStyleValue1 :附标题与祝标题平行显示,图片显示

       // style = UITableViewCellStyleValue2 :附标题显示,图片不显示

       // style = UITableViewCellStyleSubtitle :附标题与主标题上下显示,图片显示

        NSString *subtitle = [NSString stringWithFormat:@"产品-%ld很好",indexPath.row + 1];

        

        cell.detailTextLabel.text = subtitle;

        

        //设置右边的图标

        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

        

        return cell;

    }

    // 设置cell的高度继承delegate的方法:不仅要<UITableViewDataSource, UITableViewDelegate>,还要把控制器跟tableview的dataSource连线)

    -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

        return 70;

     }

  • 相关阅读:
    关于数据库的索引知识
    RESTful API设计相关
    Coroutine(协程)模式与线程
    Python网络编程中的服务器架构(负载均衡、单线程、多线程和同步、异步等)
    读懂diff
    Linux学习笔记——如何使用echo指令向文件写入内容
    ubuntu中执行定时任务crontab
    网络编程之异步IO,rabbitMQ笔记
    走进docker的世界之入门篇
    xml基础
  • 原文地址:https://www.cnblogs.com/yuyu-2012/p/4642378.html
Copyright © 2011-2022 走看看