iOS tableView在应用中一些技巧

1.去掉tableView的分割线animation

     1>self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;it

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

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

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

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

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

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

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

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

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

相关文章
相关标签/搜索