Eliminate extra separators below UITableView(消除 UITableView 下面多余的分隔符)
问题描述
当我设置一个有 4 行的表格视图时,在填充的行下方仍然有额外的分隔线(或额外的空白单元格).
When I set up a table view with 4 rows, there are still extra separators lines (or extra blank cells) below the filled rows.
如何删除这些单元格?
推荐答案
界面生成器(iOS 9+)
只需将 UIView 拖到表格中即可.在情节提要中,它将位于自定义单元格下方的顶部.您可能更愿意将其命名为页脚".
Interface builder (iOS 9+)
Just drag a UIView to the table. In storyboard, it will sit at the top below your custom cells. You may prefer to name it "footer".
为了清楚起见,这里显示为绿色,您可能需要清晰的颜色.
Here it is shown in green for clarity, you'd probably want clear color.
请注意,通过调整高度,您可以根据自己的喜好影响桌子底部弹跳"的处理方式.(高度为零通常很好).
Note that by adjusting the height, you can affect how the "bottom bounce" of the table is handled, as you prefer. (Height zero is usually fine).
以编程方式进行:
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.tableFooterView = UIView()
}
目标-C
iOS 6.1+
- (void)viewDidLoad
{
[super viewDidLoad];
// This will remove extra separators from tableview
self.tableView.tableFooterView = [UIView new];
}
或者,如果您愿意,
self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];
iOS 历史上:
添加到表格视图控制器...
Historically in iOS:
Add to the table view controller...
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section {
// This will create a "invisible" footer
return CGFLOAT_MIN;
}
如果有必要...
- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{
return [UIView new];
// If you are not using ARC:
// return [[UIView new] autorelease];
}
这篇关于消除 UITableView 下面多余的分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:消除 UITableView 下面多余的分隔符


- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01