• 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
  • 相关阅读:
    POJ 2234 Matches Game 尼姆博弈
    复杂问题的简单抽象:魔兽世界中的兔子们
    POJ 2368 巴什博奕
    POJ 1067 取石子游戏 威佐夫博弈
    Codeforces 704A Thor 队列模拟
    Codeforces 703B Mishka and trip
    P1447 [NOI2010]能量采集
    P2652 同花顺
    P2034 选择数字 / P2627 [USACO11OPEN]Mowing the Lawn G
    P2515 [HAOI2010]软件安装
  • 原文地址:https://www.cnblogs.com/wwjwb/p/12650831.html
Copyright © 2020-2023  润新知