myTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
2.系统默认的cell点击后的颜色设置
cell.selectionStyle=UITableViewCellSelectionStyleNone; //无色
cell.selectionStyle=UITableViewCellSelectionStyleBlue; //蓝色
cell.selectionStyle = UITableViewCellSelectionStyleGray; //灰色
3.设置TableView分割线的颜色
[myTableView setSeparatorColor:[UIColor xxxx ]];//可以通过RGB设置
4.控制TableView分割线的长度和缩进
myTableView.separatorInset = UIEdgeInsetsMake(0, 10, 10, 10);
UIEdgeInsets UIEdgeInsetsMake
(
CGFloat top,
CGFloat left,
CGFloat bottom,
CGFloat right
);
5.在UITableViewStylePlain风格下消除TableView多余的单元格横线
[myTableView setTableFooterView:[[UIView alloc]init]];
6.消除ios7以上,TableView默认上方留有空余
self.automaticallyAdjustsScrollViewInsets =NO;
写在- (void)viewDidLoad里面即可
7.设置TableView不能滚动
self.tableView.scrollEnabled =NO;
8.tableview刷新某一组(带动画)
NSIndexSet *indexSet=[[NSIndexSet alloc]initWithIndex:2];
[tableview reloadSections:indexSet withRowAnimation:UITableViewRowAnimationAutomatic];
9.tableview刷新某一行或者某几行(带动画)
NSIndexPath *indexPath=[NSIndexPath indexPathForRow:3 inSection:0];
[tableView reloadRowsAtIndexPaths:[NSArray arrayWithObjects:indexPath,nil] withRowAnimation:UITableViewRowAnimationNone];
10.获取tableview的某一行cell后修改cell内容
当我们点击某个cell时,会执行下面这个方法,方法中调用另一方法执行具体操作:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (0 == indexPath.section) {
[self btnActionForUserSetting:self];
}
}
- (void)btnActionForUserSetting:(id) sender {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
cell.textLabel.text= @"abc";
}
//cell = (BKCell *)button.superview;//button为cell上的button
cell = (BKCell *)button.superview.superview;
//获取位置
NSIndexPath *index = [TableView indexPathForCell:cell];
NSArray *arr = [[NSArray alloc] initWithObjects:index, nil];
//删除掉选中的cell
[TableView deleteRowsAtIndexPaths:arr withRowAnimation:UITableViewRowAnimationLeft];