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

  • 相关阅读:
    yii2 页面渲染方法解析
    JavaScript 编码小技巧
    Ansible Playbooks入门介绍
    CentOS 7 源码安装Ansible 2.x
    GitLab 安装与入门
    SpringBoot 悲观锁 与 乐观锁
    SpringBoot 事务隔离性和传播性
    SpringBoot 定义通过字段验证
    SpringBoot 密码MD5加密
    SpringBoot MockMVC
  • 原文地址:https://www.cnblogs.com/hongyan1314/p/5790007.html
Copyright © 2011-2022 走看看