亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

減少UITableView部分之間的空間

減少UITableView部分之間的空間

守著一只汪 2019-12-13 09:50:03
有沒有辦法減少UITableView的兩個部分之間的空間?我擁有的每個部分之間大約有15個像素。我確實已經嘗試過為返回0 -tableView:heightForFooterInSection:,-tableView:heightForHeaderInSection:但這并沒有改變任何東西。有什么建議么?
查看完整描述

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。


查看完整回答
反對 回復 2019-12-13
?
POPMUISE

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結合使用)


查看完整回答
反對 回復 2019-12-13
?
慕尼黑5688855

TA貢獻1848條經驗 獲得超2個贊

您必須減少節的頁眉/頁腳高度。然后,節之間的空間將減小。


試試這個代碼


這個對我有用 :-)


tableView.sectionHeaderHeight = 2.0;

tableView.sectionFooterHeight = 2.0;


查看完整回答
反對 回復 2019-12-13
  • 3 回答
  • 0 關注
  • 669 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號