2011-09-06 49 views
0

任何想法,为什么我不能减少/删除分组UITableView中的单元格之间的空间(每节一个单元格)。我在控制器中包含以下内容:减少UITableView中单元格之间的空间 - 为什么这段代码不会执行此操作?

- (CGFloat) tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section { 
    return 0.0; 
} 

- (CGFloat) tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section { 
    return 0.0; 
} 

即使使用此代码,单元格之间仍然存在空格。在单元格周围放置一个边框,并且这些空格不是来自单元格本身。

+0

[减小的UITableView的部分之间的空间]的可能重复(http://stackoverflow.com/questions/2817308/reducing-the-space-between-sections-of-the-uitableview) – PengOne

+0

特别是,神奇的解决方案是[这里](http://stackoverflow.com/questions/2817308/reduce-the-space-between-sections-of-the-uitableview/2817696#2817696) – PengOne

+0

谢谢 - “魔法解决方案”链接 - 这工作 - 你知道为什么需要显式分配页眉/页脚视图像在“viewForHeaderInSection”中获取乐于工作? – Greg

回答

0

按PengOne的建议,看看答案here,我并没有到位,使得它的工作都有了以下内容:

-(UIView*)tableView:(UITableView*)tableView viewForHeaderInSection:(NSInteger)section 
{ 
    return [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)] autorelease]; 
} 

-(UIView*)tableView:(UITableView*)tableView viewForFooterInSection:(NSInteger)section 
{ 
    return [[[UIView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)] autorelease]; 
} 
相关问题