3 回答

TA貢獻1934條經驗 獲得超2個贊
這有點棘手,但是請嘗試以下代碼:
- (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。

TA貢獻1765條經驗 獲得超5個贊
對于所有想要將距離縮小到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];
}
(將iOS 4.1與XCode 4.0.2結合使用)

TA貢獻1848條經驗 獲得超2個贊
您必須減少節的頁眉/頁腳高度。然后,節之間的空間將減小。
試試這個代碼
這個對我有用 :-)
tableView.sectionHeaderHeight = 2.0;
tableView.sectionFooterHeight = 2.0;
- 3 回答
- 0 關注
- 669 瀏覽
添加回答
舉報