zoukankan      html  css  js  c++  java
  • iOS tableView在应用中一些技巧

    1.去掉tableView的分割线

         1>self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

         2> self.tableView.separatorColor =[UIColor clearColor];

    2.点击tableView时去掉灰色效果
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES]

    3. 让tableView滚动到最顶部
    [self.tableView setContentOffset:CGPointMake(0,0) animated:YES];

    4. 中让tableView刷新某一行数据
    NSIndexPath * idxPath = [NSIndexPath indexPathForRow:<#(NSInteger)#> inSection:<#(NSInteger)#>];

    [self.taleView reloadPowAtIndexPaths:@[idxPath] withRowAnimation:UITableViewRowActionStyleDefault];

    5.设置tableView的行不允许被选中
         1>self.tableview.allowsSelection=NO;

         2>self.tableView.userInteractionEnabled =NO;(这种情况对于cell较少的好使,但是当cell较多时不能用它,因为他会把tableView给禁止掉,导致不能滑动)

         3>直接加蒙版,设置view。

    6. 中让tableView的最后一行滚动到最上面
    NSIndexPath * idxPath = [NSIndexPath indexPathForRow:<#(NSInteger)#> inSection:<#(NSInteger)#>];

    [self.taleView scrollToRowAtIndexPaths:idxPath atScrollPosition:UITableViewScrollPositionTop annimated:YES];

    7.总结tableview的刷新

          1>- (void)reloadData;刷新整个表格。

          2>- (void)reloadRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation 刷新指定的分组和行。

         3.>- (void)reloadSections:(NSIndexSet *)sections withRowAnimation:(UITableViewRowAnimation)animation 刷新指定的分组。

         4>- (void)deleteRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;删除时刷新指定的行数据。

         5>- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths withRowAnimation:(UITableViewRowAnimation)animation;添加时刷新指定的行数据。

    8.设置tableView分割线颜色

    self.tableView.separatorColor =[UIColor readColor];

  • 相关阅读:
    <<构建之法>>--第二次作业
    锁的内存语义
    MySQL触发器
    每天一个小示例 opencv(1)颜色直方图的统计 calcHist_Demo.cpp
    通过支持向量排名法来做行人鉴定
    数字信号处理101——DSP系统设计入门课程(1)
    matlab 与c++的混编
    FPGA图像处理之行缓存(linebuffer)的设计一
    基于FPGA的数字识别的实现
    使用matlab生成sine波mif文件
  • 原文地址:https://www.cnblogs.com/hongyan1314/p/5790007.html
Copyright © 2011-2022 走看看