【问题标题】:Remove space at the top of first row in table view删除表格视图中第一行顶部的空格
【发布时间】:2014-01-18 09:23:52
【问题描述】:
在我的应用程序中,我使用表格视图中的自定义单元格在所有行中显示图像。但是在我的 .xib 文件中,自定义单元格的顶部有一个很大的空白区域。谁能告诉我如何在 iOS7 (iPad) 中删除该空间? (比如如何改变自定义单元格的Y轴)
【问题讨论】:
标签:
ios
objective-c
uitableview
ios6
ios7
【解决方案1】:
这是与 UITableViewStyleGrouped 和节中页脚视图大小有关的 IOS7 相关问题。
如果您将footerView 设置为大小0,它默认为一个更大的值,我找到的解决方案是将页脚设置为一个非常小的非零数字
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.0000001f;
}
【解决方案3】:
这可能会对您有所帮助:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
UILabel *sectionHeader = [[UILabel alloc] initWithFrame:CGRectNull];
sectionHeader.hidden = YES;
return sectionHeader;
}
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
return 0;
}
有时第一行的空白区域是节标题空间。这个函数消除了它。