首页 > 移动平台 > 详细

iOS tableView在应用中一些技巧

时间:2016-08-20 12:59:32      阅读:139      评论:0      收藏:0      [点我收藏+]

1.去掉tableView的分割线
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

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;添加时刷新指定的行数据。

iOS tableView在应用中一些技巧

原文:http://www.cnblogs.com/hongyan1314/p/5790007.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!