tableView

来源:互联网 发布:python 列表生成字典 编辑:程序博客网 时间:2024/05/16 12:08
iOS8 , 自动计算Cell高度
// 告诉tableView的真实高度是自动计算的,根据你的约束来计算
self.tableView.rowHeight = UITableViewAutomaticDimension;
// 告诉tableView所有cell的估计行高
self.tableView.estimatedRowHeight = 44


 row 刷新
<span style="font-size:14px;">NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1inSection:0];[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationNone];</span>

section 刷新
<span style="font-size:14px;">NSIndexSet *indexSet = [NSIndexSet indexSetWithIndex:0];[self.tableView reloadSections:indexSet withRowAnimation:UITableViewRowAnimationNone];</span>

headerview黏性
<span style="font-size:14px;">#pragma mark - scrollView delegate//delete UItableview headerview黏性- (void)scrollViewDidScroll:(UIScrollView *)scrollView {    if (scrollView == self.tableView)    {        CGFloat sectionHeaderHeight = 10;        if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {            scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);        } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {            scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);        }    }    [self.view endEditing:YES];}</span>

设置字母索引背景色为透明
//设置字母索引背景色为透明if ([self.tableView respondsToSelector:@selector(setSectionIndexColor:)]) {self.tableView.sectionIndexBackgroundColor = [UIColor clearColor];self.tableView.sectionIndexTrackingBackgroundColor = [UIColor clearColor];//设置字母索引文字颜色self.tableView.sectionIndexColor = DWDColorMain;}

解决ios8及以上分割线有边緣问题
// 解决ios8及以上 分割线有边緣问题-(void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath{    if ([cell respondsToSelector:@selector(setSeparatorInset:)]) {        [cell setSeparatorInset:UIEdgeInsetsZero];    }    if ([cell respondsToSelector:@selector(setLayoutMargins:)]) {        [cell setLayoutMargins:UIEdgeInsetsZero];    }}// 解决ios8及以上 分割线有边緣问题-(void)viewDidLayoutSubviews{    if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {        [self.tableView setSeparatorInset:UIEdgeInsetsZero];    }    if ([self.tableView respondsToSelector:@selector(setLayoutMargins:)]) {        [self.tableView setLayoutMargins:UIEdgeInsetsZero];    }}

设置区头颜色
//设置区头颜色- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{    UITableViewHeaderFooterView *v = (UITableViewHeaderFooterView *)view;    v.backgroundView.backgroundColor = [UIColor blackColor];}

0 0
原创粉丝点击