您的位置:首页 > 产品设计 > UI/UE

UITabelView section headerView浮动问题

2014-07-09 23:37 218 查看
解决方案一:

headerView 直接添加到 self.tableView.headerView 中

解决方案二:(多 section 情况下建议使用)

更改 TabelViewStyle 为 Grouped

UITableViewStyleGrouped 多个 section之间  间距调整

显示效果的各个section间距其实是section头部和底部的组合。配置他们的间距就是配置各个section的头部和底部。

经过测试,height = 1时 无法实现更改,设置为1.1即可

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
return 1;//section头部高度
}
//section头部视图
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
view.backgroundColor = [UIColor clearColor];
return [view autorelease];
}
//section底部间距
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 1;
}
//section底部视图
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
UIView *view=[[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1)];
view.backgroundColor = [UIColor clearColor];
return [view autorelease];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: