- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 UITableView,在某些情况下,某些部分的行数为零。我的目标是,当这是真的时,我不希望 TableView 中出现任何浪费的空间,它应该看起来没有数据。
我遇到的问题是各部分的页眉和页脚,即使没有行并且尽管我重写了委托(delegate)方法以返回 0.0f,它们也会显示。
它看起来是这样的 - 您可以看到顶部有约 20p 的灰色空间,对于 0 行的部分,页眉和页脚各约为 10p。
(来源:hanchorllc.com)
这是我的伪代码:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
if ([section hasRow]) {
return 10.0f;
} else {
return 0.0f;
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
if ([section hasRow]) {
return 10.0f;
} else {
return 0.0f;
}
}
我已经验证这些方法正在被调用并且正在发生正确的执行路径。
一个问题 - 该 View Controller 使用 XIB,并且 UITableView 将节页眉和页脚值设置为 10.0(默认),尽管我认为如果实现的话,它会被委托(delegate)方法覆盖。
这是一个面向 3.0 的应用。
我做错了什么?
最佳答案
这有点棘手,因为 0.0f 值不被接受。但任何足够接近零的值都可以解决问题。如果您决定不追求像素完美并想要整数,那么 1.0f 的效果几乎相同,因为 1px 的高度差异将相当明显。
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
if(section == 1 )
return 0.000001f;
else return 44.0f; // put 22 in case of plain one..
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
return 0.000001f; //removing section footers
}
关于iphone - UITableView 不尊重 heightForHeaderInSection/heightForFooterInSection?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1386826/
我有一个 UITableView,在某些情况下,某些部分的行数为零。我的目标是,当这是真的时,我不希望 TableView 中出现任何浪费的空间,它应该看起来没有数据。 我遇到的问题是各部分的页眉和页
这是 tableView:heightForFooterInSection: 未实现时的样子: 一旦我将这一行添加到代码中: func tableView(tableView: UITableView
我正在调试一个 iOS 应用程序(不是 iOS 开发人员)来尝试为客户解决一个错误,因为我们的 iOS 开发人员不在,所以很抱歉,因为这可能是显而易见的。该应用程序崩溃并显示以下错误消息: 2019-
我做了: [tableView setNeedsLayout] 和 [tableView setNeedsDisplay],但是这不会调用该委托(delegate)。有没有一种方法可以在不重新加载数据
我是一名优秀的程序员,十分优秀!