简体   繁体   English

我应该在哪里将子视图添加到UITableViewController中的表视图下?

[英]Where should I add my subview to have it UNDER my table view in a UITableViewController?

I'm using parse's PFQueryTableViewController , which is almost exactly the same as a UITableViewController except it handles some querying in the background. 我正在使用parse的PFQueryTableViewController ,它与UITableViewController PFQueryTableViewController ,只不过它在后台处理一些查询。

My goal is to place a static toolbar at the bottom of the screen. 我的目标是在屏幕底部放置一个静态工具栏。 I decided to do this by giving tableView a smaller frame, and creating and adding my toolbar subview below the tableView , as a subview to the same view that the tableView is a subview of. 我决定通过给tableView一个较小的框架,并在tableView下面创建和添加我的工具栏子视图来实现此目的,以作为tableView所在子视图的同一视图的子视图。

Here's a photo. 这是一张照片。 I am trying to add my toolbar to the little white space at the bottom of the screen. 我试图将工具栏添加到屏幕底部的空白处。 That whitespace does NOT scroll with the table view: 该空格不随表格视图滚动:

在此处输入图片说明

I have tried [self.view addSubview: toolbar] , however, this just adds it to the tableView, and as a result, my toolbar scrolls with it. 我尝试过[self.view addSubview: toolbar] ,但是,这只是将其添加到tableView中,结果,我的工具栏随之滚动。 I can't seem to find any documentation on the view hierarchy for a UITableViewController. 我似乎找不到关于UITableViewController的视图层次结构的任何文档。 Anyone know where I should add my toolbar subview? 有人知道我应该在哪里添加工具栏子视图吗? I should also mention that all of this is sitting inside of a UINavigationController . 我还应该提到,所有这些都位于UINavigationController内部。

A PFQueryTableViewController (like all UITableViewController s) has a table view as its view . PFQueryTableViewController (像所有UITableViewController一样)具有一个表视图作为其view

If you want to have other views within the view controller, either don't use a table view controller, or subclass UINavigationController . 如果要在视图控制器中包含其他视图,请不要使用表视图控制器或UINavigationController子类。

Alternatively, you can set the view controller's toolbarItems property, and the navigation controller will take care of making and configuring a standard toolbar. 另外,您可以设置视图控制器的工具栏toolbarItems属性,导航控制器将负责制作和配置标准工具栏。

implement viewFAorHeaderInSection delegate method of UITableView: 实现UITableView的viewFAorHeaderInSection委托方法:

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
 {

    UIView* customView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, tableView.frame.size.width, 90)];
    customView.backgroundColor = [UIColor blackColor];
    return customView;
 }

and heightForFooterInSection 和heightForFooterInSection

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
return 80;
}

it should solove your problem. 它应该解决您的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何以编程方式向我的UITableViewController添加活动指示器视图? - How do I add an activity indicator view to my UITableViewController programmatically? 将 UIView 作为子视图添加到 UITableViewController 的视图 - Add a UIView as a subview to a UITableViewController's view 以编程方式加载UITableViewController并将视图添加为子视图 - Load UITableViewController programmatically and add view as subview 如何在表格视图的每个单元格下添加行? - How can I add lines under each cell in my table view? 我的 UITableViewController 中的 memory 泄漏在哪里? - Where is the memory leak in my UITableViewController? 将视图添加为子视图时,为什么看不到整个选项卡栏? - Why can't i see my whole tab bar when i add it in a view as subview? 我应该在哪里定义所有视图对象? - Where should i define all my view objects? 我可以从另一个视图中添加NSMutableArray中的对象(可能是它的子视图) - Can I add object in my NSMutableArray from another view (may be it's subview) 我的游戏中应该有几个View Controller? - How many View Controllers should I have in my game? 我应该将底页作为子视图添加到当前视图控制器,还是应该在添加了SubView的情况下推送UIWindow? - Should I add bottom sheet as a subview to current view controller or push a UIWindow with the subView added?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM