zoukankan      html  css  js  c++  java
  • iOS UITableview

    1. UITableView

    //去除tableviews的点击效果
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
     
     //隐藏tableView的分割线
    cell.tableView.separatorStyle = UITableViewCellSelectionStyleNone; 
    /*

     UITableViewCellSeparatorStyleNone,

        UITableViewCellSeparatorStyleSingleLine,

        UITableViewCellSeparatorStyleSingleLineEtched 只适用于tableView为分段的风格

    */
     
    //根据cell的位置获得某个cell
    SecondTableViewCell *cell = (SecondTableViewCell *)[self.tableViewcellForRowAtIndexPath:[NSIndexPathindexPathForRow:2inSection:0]];
     
    //设置行高为动态
    tableView.rowHeight = UITableViewAutomaticDimension;
     
    //cell的预估行高
    tableView.estimatedRowHeight = 44;
    点击状态栏回到顶部
    tableView.scrollsToTop = YES;
     
    //刷新一个section
    NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2]; 
    [tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];      
    //一个cell刷新    
    NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];
    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
     
    实现这个新的delegate函数即可:可以设置背景色
    - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section { view.tintColor = [UIColor clearColor]; }
    改变文字的颜色
    - (void)tableView:(UITableView *)tableView willDisplayFooterView:(UIView *)view forSection:(NSInteger)section { UITableViewHeaderFooterView *footer = (UITableViewHeaderFooterView *)view; [footer.textLabel setTextColor:[UIColor whiteColor]]; }
     
    cell的4种格式
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
        UITableViewCell *cell;
        switch (indexPath.row) {
            case 0:
            {
                cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CELL1];
                cell.backgroundColor = [UIColor yellowColor];
                cell.selectionStyle = UITableViewCellSelectionStyleDefault;
            }
                break;
            case 1:
            {
                cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CELL2];
                cell.backgroundColor = [UIColor redColor];
                cell.selectionStyle = UITableViewCellSelectionStyleGray;
            }
                break;
            case 2:
            {
                cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CELL2];
                cell.backgroundColor = [UIColor blueColor];
                cell.selectionStyle = UITableViewCellSelectionStyleBlue;
            }
                break;
            case 3:
            {
                cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CELL4];
                cell.backgroundColor = [UIColor purpleColor];
                cell.selectionStyle = UITableViewCellSelectionStyleDefault;
            }
                break;
        }
        cell.imageView.image = [UIImage imageNamed:@"warning_btn"];
        cell.detailTextLabel.text = @"detailTextLabel";
        cell.textLabel.text = @"textLabel";
        return cell;
    }

      
     
    有兴趣的可以加入QQ群:457236811
  • 相关阅读:
    CSS3圆圈动画放大缩小循环动画效果
    php将多个值的数组去除重复元素
    .net 图片压缩
    关于FFmpegInterop项目的编译
    Axure Beta 7.0 汉化版下载
    axure 6.5 汉化正式版软件及注册码
    HTML基础复习(八)表单
    HTML基础复习(七)布局-div间距
    Android+GPS轨迹跟踪器(一)
    HTML基础复习(六)布局-居中
  • 原文地址:https://www.cnblogs.com/ljmaque/p/UITableView.html
Copyright © 2011-2022 走看看