再添加tableviewheader時注意

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section

使用此方法添加header的时候,header不会随着tableview的滚动而滚动

需要注意,重写自定义header(继承自uiview)的setFrame方法,

- (void)setFrame:(CGRect)frame

{

    CGRect sectionRect = [self.tableView rectForSection:self.section];

    CGRect resultFrame = CGRectMake(CGRectGetMinX(frame), CGRectGetMinY(sectionRect), CGRectGetWidth(frame), CGRectGetHeight(frame));

    [super setFrame:resultFrame];

}

posted @ 2016-01-18 11:11  锄,禾日当午  阅读(125)  评论(0编辑  收藏  举报