减少UITableView部分之间的空间

有没有办法减少UITableView的两个部分之间的空间?我拥有的每个部分之间大约有15个像素。我确实已经尝试过为返回0 -tableView:heightForFooterInSection:-tableView:heightForHeaderInSection:但这并没有改变任何东西。

有什么建议么?


守着一只汪
浏览 576回答 3
3回答

撒科打诨

这有点棘手,但是请尝试以下代码:- (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。

POPMUISE

对于所有想要将距离缩小到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结合使用)

慕尼黑5688855

您必须减少节的页眉/页脚高度。然后,节之间的空间将减小。试试这个代码这个对我有用 :-)tableView.sectionHeaderHeight = 2.0;tableView.sectionFooterHeight = 2.0;
打开App,查看更多内容
随时随地看视频慕课网APP