2011-06-17 72 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

相关问题