手动将UITabBar添加到UITableViewController [英] manually add UITabBar to UITableViewController

查看:49
本文介绍了手动将UITabBar添加到UITableViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有导航控制器的标准应用程序,该控制器管理多个UITableViewController类.

I have a standard app with a navigation controller managing several UITableViewController classes.

我想将UITabBar添加到根视图(一个UITableViewController)中,以管理对UITableView中显示的对象选择的过滤.

I want to add a UITabBar to the root view (a UITableViewController) to manage filtering the selection of objects showin in the UITableView.

我不需要/不需要UITabBarController. UITabBar仅适用于功能和UI(单选按钮样式选择和熟悉的标签栏UI).我只想手动创建一个UITabBar并将其添加到锚定/锁定到屏幕最底部的视图中,就像使用UITabBarControllers时一样.

I dont want/need a UITabBarController. The UITabBar is only for functionality and UI (radio-button style selection and familiar tabbar UI). I just want to manually create a UITabBar and add it to my view anchored/locked to the very bottom of the screen like is the case when using UITabBarControllers.

我的主要问题是我也弄不清楚应该将UITabBar添加为子视图的原因.

My main problem is I can't figure out what I should be adding the UITabBar as a subview too.

我不想将其添加到控制器self.tableView中,因为那样它会被锚定在滚动TableView的底部,并且并不总是在屏幕底部可见.

I dont want to add it to the controllers self.tableView because then it would be achored to the bottom of the scrolling TableView and not always visible on the bottom of the screen.

我还尝试将其添加到view.tableView.superview中,但这似乎也不起作用.

I also tried adding to the view.tableView.superview but that didnt seem to work as well.

有什么帮助,还是我完全在做错误地过滤tableview数据",应该使用其他方法代替吗?

Any help, or am I completely doing this "filtering of tableview data the wrong way" and should be using something else instead?

推荐答案

因此,UITableViewController的问题在于它不能像您期望的那样正常工作.将'locked'元素添加到UITableView非常困难-表脚和页眉无法完成工作,并且您发现将其添加到Superview中是行不通的.

So, the problem with a UITableViewController is it doesn't quite work as you might expect. It's very difficult to add 'locked' elements to a UITableView - the table footers and headers don't do the job, and as you've discovered adding it to the superview doesn't work.

在这种情况下,最好的解决方案实际上是将表视图控制器扔出窗口,并使用具有常规视图控制器的表视图.

The best solution in this case is actually to throw the table view controller out the window, and use a table view with a normal view controller.

您想要做的是创建一个普通的UIViewController,然后向其中添加一个表视图.您的表视图委托和数据源也可以在此视图控制器中.

What you want to do is create a normal UIViewController, and then add a table view to it. Your table view delegate and datasource can also be in this view controller.

然后可以将表格视图的大小调整为小于屏幕大小,然后将UITabBar添加到视图控制器的主视图.

You can then resize your table view to be smaller than the size of the screen, and add your UITabBar to the view controller's main view.

这篇关于手动将UITabBar添加到UITableViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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