有没有办法减少UITableView的两个部分之间的空间?在我的每个单独的部分之间大约有15个像素。我已经尝试为-tableView:heightForFooterInSection:
和-tableView:heightForHeaderInSection:
返回0,但这不会改变任何事情。
有什么建议吗?
发布于 2010-05-12 17:59:31
这有点棘手,但试一下下面的代码:
- (CGFloat)tableView:(UITableView*)tableView
heightForHeaderInSection:(NSInteger)section {
if (section == 0) {
return 6.0;
}
return 1.0;
}
- (CGFloat)tableView:(UITableView*)tableView
heightForFooterInSection:(NSInteger)section {
return 5.0;
}
- (UIView*)tableView:(UITableView*)tableView
viewForHeaderInSection:(NSInteger)section {
return [[UIView alloc] initWithFrame:CGRectZero];
}
- (UIView*)tableView:(UITableView*)tableView
viewForFooterInSection:(NSInteger)section {
return [[UIView alloc] initWithFrame:CGRectZero];
}
相应地更改这些值。为了删除空格,我认为0.0不会被接受。最小的合理值似乎是1.0。
发布于 2011-09-12 22:04:43
对于所有想要将距离缩小到0的人,您必须使用:
tableView.sectionHeaderHeight = 0.0;
tableView.sectionFooterHeight = 0.0;
因为UITableViewDelegate的服务只产生从大于零的浮点数开始的效果。
-(CGFloat)tableView:(UITableView*)tableView heightForHeaderInSection:(NSInteger)section
{
return 1.0;
}
-(CGFloat)tableView:(UITableView*)tableView heightForFooterInSection:(NSInteger)section
{
return 1.0;
}
-(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section
{
return [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
}
-(UIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section
{
return [[[UIView alloc] initWithFrame:CGRectZero] autorelease];
}
(在XCode 4.0.2中使用iOS 4.1 )
发布于 2011-01-27 11:27:45
实际上,您可以在Interface Builder的size选项卡下设置页脚/页眉/单元格的高度。默认情况下,页眉/页脚设置为10.0。
https://stackoverflow.com/questions/2817308
复制相似问题