2011-09-06 14 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]; 
} 
相關問題