• 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];

  • 相关阅读:
    linux中bin和sbin目录的主要区别
    C# 值类型 引用类型 作为参数传递区别
    绿色免安装电视直播软件viviplayer
    [转]中科大校长建议停止以行政主导的高校评估
    MDS 7.0 使用中的问题 2(数据交换中图元的丢失)
    怪异的慢递公司一统快递
    [转]全国最好的医院列表
    多普达D600 问题集锦
    推荐PDG阅读器UnicornViewer
    [转]《乒乓世界》封面故事:中国男乒直板三人行
  • 原文地址:https://www.cnblogs.com/hongyan1314/p/5790007.html
Copyright © 2020-2023  润新知