flo*_*hei 139 iphone uitableview ios
有没有办法减少UITableView的两个部分之间的空间?每个部分之间大约有15个像素.我确实已经尝试返回0 -tableView:heightForFooterInSection:,-tableView:heightForHeaderInSection:但这并没有改变任何东西.
有什么建议?
Tom*_*men 261
这有点棘手,但请尝试以下代码:
- (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];
}
Run Code Online (Sandbox Code Playgroud)
相应地更改值.要删除空格,我认为不会接受0.0.最小的理智值似乎是1.0.
Mar*_*olz 141
对于想要将距离缩小到0的所有人,您必须使用:
tableView.sectionHeaderHeight = 0.0;
tableView.sectionFooterHeight = 0.0;
Run Code Online (Sandbox Code Playgroud)
因为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];
}
Run Code Online (Sandbox Code Playgroud)
(使用iOS 4.1和XCode 4.0.2)
小智 33
您可以在"大小"选项卡下的Interface Builder中实际设置页脚/页眉/单元格高度.默认情况下,页眉/页脚设置为10.0.
Jir*_*une 27
您必须减少节页眉/页脚高度.然后部分之间的空间将减少.
试试这段代码
这个对我有用 :-)
tableView.sectionHeaderHeight = 2.0;
tableView.sectionFooterHeight = 2.0;
Run Code Online (Sandbox Code Playgroud)
ios*_*tor 21
您还可以从故事板中减小部分页脚和页眉的高度.在tableview - > size inspector中.转到章节高度.

默认情况下,对于普通样式表,它设置为22,对于分组样式表,它设置为10.您可以通过分别增加/减少页眉和页脚的值来配置值.
对我来说,问题是因为我使用的是分组的表格视图样式(UITableViewStyleGrouped)。当我将其更改为简单样式(UITableViewStylePlain)时,我的tableView:heightForHeaderInSection:方法是确定每个节标题的大小的唯一方法。
也许使用这个,0 不会按预期工作
func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
return .leastNormalMagnitude
}
func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
return .leastNormalMagnitude
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
88205 次 |
| 最近记录: |