標籤:
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在應用中一些技巧