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

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

问题描述

我正在尝试在 uitableview 控制器表视图的顶部添加一个按钮.视图控制器有一个导航控制器和静态单元格,这就是为什么它是一个 uitableviewcontroller 而不是一个 uiviewcontroller.现在我正在尝试在屏幕底部添加一个按钮,该按钮连接到导航控制器,这样它就不会随着表格视图滚动.

我正在尝试制作类似于下面的内容.它有一个用于顶部栏的导航控制器、一个带有静态单元格的表格视图和一个按钮,但是它们是如何实现按钮的呢?

图片:

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

结果:

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?

Image: http://postimg.org/image/ilsmqqrip/

Thanks!

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.

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).

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

Result:

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

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