在UITableViewController顶部添加按钮(Swift) [英] Add button on top of UITableViewController (Swift)

查看:198
本文介绍了在UITableViewController顶部添加按钮(Swift)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在uitableview控制器表视图的顶部添加一个按钮.视图控制器具有导航控制器和静态单元格,这就是为什么它是uitableviewcontroller而不是uiviewcontroller的原因.现在,我试图在屏幕底部添加一个附加到导航控制器的按钮,以使其不随表格视图滚动.

I am trying to add a button ontop of a uitableview controller table view. The view controller has a navigation controller and static cells, which is why it is a uitableviewcontroller and not a uiviewcontroller. Now I am trying to add a button at the bottom of the screen that is attached to the navigation controller so that it doesn't scroll with the table view.

我正在尝试做出类似于以下内容的内容.它有一个用于顶部栏的导航控制器,一个带有静态单元格的表格视图以及一个按钮,但是按钮是如何工作的?

I am trying to make something similar to what is below. It has a navigation controller for the top bar, a table view with static cells and then a button, but how did they do the button?

图片: http://postimg.org/image/ilsmqqrip/

谢谢!

更新:如何使用Swift使用带有静态单元格的tableview的uiviewcontroller?

UPDATE: How can I use a uiviewcontroller with a tableview with static cells using Swift?

推荐答案

在这种情况下,我发现容器视图非常有用!一个干净的解决方案,很容易实现.

I find Container Views very useful in this scenario! A clean solution and very easy to implement.

只需创建一个普通的UIViewController,将您的按钮和ContainerView添加为该UIViewController的子视图(下图中的中间一个).最后,从ContainerView创建Embed Segue到您的UITableViewController(在右侧).

Just create a normal UIViewController, add your button and a ContainerView as subviews of this UIViewController (the middle one in the image below). Finally create Embed Segue from ContainerView to your UITableViewController (the one on the right).

这样,您可以使用静态单元格原型,而不仅限于同时使用UITableView.

This way you can use static cell prototypes, not being limited only to UITableView at the same time.

结果:

这篇关于在UITableViewController顶部添加按钮(Swift)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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