2011-06-17 103 views

回答

57

您可以通過更改表視圖從UIScrollView繼承的contentInset屬性來執行此操作。

self.tableView.contentInset = UIEdgeInsetsMake(-20, 0, -20, 0); 

這將使頂部和底部接觸邊緣。

+0

感謝您的回答,但它實際上不是我說的反彈。我想要去除的是大約10px-20px,位於表格視圖的頂部和顯示的第一個單元格之間,頁腳是相同的。 – cgossain 2011-06-17 03:23:16

+0

@cgossain更新了我的答案。 – 2011-06-17 03:31:06

+0

謝謝你,這是一個更優雅的解決方案。事實證明,30像素是我需要的量。 – cgossain 2011-06-17 21:42:51

-4

使用UIScrollViewbounces屬性:

[yourTableView setBounces:NO];

這將刪除似乎是在你UITableView的頂部和底部的微胖。 實際上,它只是禁用tableview的滾動視圖來滾動內容的邊緣。

3

添加以下代碼:

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

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

的UIView可以在表(拖放)的頂部和底部被插入。將它們的屬性設置爲透明並且高度爲1像素。這是爲了去除單元格前面的額外填充。

0

,你也可以使用這個代碼的UITableView的第一個單元格之間消除空間..

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section 
{ 
    return 0.002f;// set this... 
} 
0

取消選中擴展邊緣下面頂欄。

enter image description here