消除UITableView下面的额外分隔符 [英] Eliminate extra separators below UITableView

查看:136
本文介绍了消除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拖动到表格中。在故事板中,它将位于您的自定义单元格下方的顶部。您可以将它命名为footer。

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()
}



Objective-C



iOS 6.1 +



Objective-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 0.01f;
 }

如有必要...

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section
{        
    return [UIView new];

    // If you are not using ARC:
    // return [[UIView new] autorelease];
}

这篇关于消除UITableView下面的额外分隔符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆