3 回答

TA貢獻(xiàn)1934條經(jīng)驗(yàn) 獲得超2個(gè)贊
這有點(diǎn)棘手,但是請(qǐng)嘗試以下代碼:
- (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];
}
相應(yīng)地更改值。要?jiǎng)h除空間,我認(rèn)為0.0將不被接受。最小的理智值似乎是1.0。

TA貢獻(xiàn)1765條經(jīng)驗(yàn) 獲得超5個(gè)贊
對(duì)于所有想要將距離縮小到0的人,都必須使用:
tableView.sectionHeaderHeight = 0.0;
tableView.sectionFooterHeight = 0.0;
因?yàn)樘峁︰ITableViewDelegate只會(huì)從大于零的浮點(diǎn)數(shù)開(kāi)始產(chǎn)生效果。
-(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];
}
(將iOS 4.1與XCode 4.0.2結(jié)合使用)

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超2個(gè)贊
您必須減少節(jié)的頁(yè)眉/頁(yè)腳高度。然后,節(jié)之間的空間將減小。
試試這個(gè)代碼
這個(gè)對(duì)我有用 :-)
tableView.sectionHeaderHeight = 2.0;
tableView.sectionFooterHeight = 2.0;
- 3 回答
- 0 關(guān)注
- 679 瀏覽
添加回答
舉報(bào)