zoukankan      html  css  js  c++  java
  • UITableView

    属性:

    //设置每一行cell的高度
        self.tableView.rowHeight
    
    //设置每一组头部的高度
        self.tableView.sectionHeaderHeight
    
    //设置每一组尾部的高度
        self.tableView.sectionFooterHeight 
    
    //设置分割线颜色
        self.tableView.separatorColor = [UIColor redColor];
    
    //设置分割线样式
        self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
    
    //设置表头控件
        self.tableView.tableHeaderView = [[UISwitch alloc] init];
    
    //设置表尾控件
        self.tableView.tableFooterView = [UIButton buttonWithType:UIButtonTypeContactAdd];
    
    //设置右边索引文字的颜色
        self.tableView.sectionIndexColor = [UIColor redColor];
    
    //设置右边索引文字的背景色
        self.tableView.sectionIndexBackgroundColor = [UIColor blackColor];

    dataSource:

    //遵守协议
    @interface ViewController () <UITableViewDataSource>
    
    @end
    
    //设置数据源
    self.tableView.dataSource = self;
    //实现数据源方法
    
    // 多少组数据
    - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView;
    
    // 每一组有多少行数据
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
    
    // 每一行显示什么内容
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
    
    // 每一组的头部
    - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section;
    
    // 每一组的尾部
    - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section

    delegate:

    //选中某一行cell就会调用这个方法
    - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
    
    //取消选中某一行cell就会调用这个方法
    - (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
    
    //返回每一组的头部控件
    - (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
    
    //返回每一组的尾部控件
    - (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
    
    //返回的每一组的头部的高度
    - (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
    
    // 返回的每一组的尾部的高度
    - (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
    
    // 返回的每一行cell的高度
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

      索引条

    //设置右边索引文字的颜色
         self.tableView.sectionIndexColor = [UIColor redColor];
    
    //设置右边索引文字的背景色
        self.tableView.sectionIndexBackgroundColor = [UIColor blackColor];
    
    //返回每一组的索引标题
        - (NSArray *)sectionIndexTitlesForTableView:(UITableView *)tableView
  • 相关阅读:
    【原】从/dev/null重新打开标准输出
    Go 接口转换的一个例子
    关于软件编译安装的出错处理
    【原】GO 语言常见错误
    HP平台由于变量声明冲突导致程序退出时的core
    动态链接库加载出错:cannot restore segment prot after reloc: Permission denied
    Windows VC++常见问题汇总
    .net:System.Web.Mail vs System.Net.Mail应该用哪个
    网络管理的功能
    Hello World! — 用 Groovy 编写的 Java 程序
  • 原文地址:https://www.cnblogs.com/wwjwb/p/12650831.html
Copyright © 2011-2022 走看看