ios 如何在 Storyboard 中为 UITableView 添加页脚

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9605381/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 17:12:23  来源:igfitidea点击:

How to add a footer to a UITableView in Storyboard

iosios5uitableviewstoryboard

提问by Jon Cox

I'm fairly new to iOS development.

我对iOS开发相当陌生。

I want to add a footer to the table view in a UITableViewController. I've made the view I want to use as the footer graphically in Storyboard, however I can't work out how to hook it up as the footer to my table view.

我想在UITableViewController. 我已经在 Storyboard 中以图形方式制作了我想用作页脚的视图,但是我不知道如何将它作为页脚连接到我的表视图。

I can add a footer programmatically in UITableViewController's viewDidLoadmethod by assigning self.tableView.tableFooterView. But I've created my footer view in Storyboard, what is the best practiceway of adding it as the footer to my table view?

我可以以编程方式添加脚注UITableViewControllerviewDidLoad通过分配方法self.tableView.tableFooterView。但是我已经在 Storyboard 中创建了我的页脚视图,将它作为页脚添加到我的表视图的最佳实践方法是什么?

回答by dbrajkovic

You can just drag a view to the bottom area of the tableView. You'll see in the hierarchy that it will be a subview of the tableview. You can then drag subviews such as labels and buttons there, adjust the height, etc.

您可以将视图拖到 tableView 的底部区域。您将在层次结构中看到它将是 tableview 的子视图。然后,您可以将子视图(例如标签和按钮)拖到那里,调整高度等。

回答by Javier Calatrava Llavería

Very simple!. dbrajkovic solution but in a graphical way. Just add a view to the table view.That's all!. enter image description here

很简单!。dbrajkovic 解决方案,但以图形方式。只需向表视图添加一个视图即可。仅此而已! 在此处输入图片说明

In that example the footer view (Disclaimer View) has two labels ( Llb Disclaimer Title and Lbl Disclaimer Content).

在该示例中,页脚视图(Disclaimer View)有两个标签(Llb Disclaimer Title 和 Lbl Disclaimer Content)。

回答by timschmitz

The above answer worked for me with one twist. I found I couldn't add a footer if the cells filled up the entire height of the table view. Removing a couple of cells allowed me to add the footer, after which I was able to add the cells back.

上面的答案对我有用。我发现如果单元格填满了表格视图的整个高度,我就无法添加页脚。删除几个单元格允许我添加页脚,之后我可以将单元格添加回来。