tableFooterView属性不会修复表视图底部的页脚 [英] tableFooterView property doesn't fix the footer at the bottom of the table view

查看:224
本文介绍了tableFooterView属性不会修复表视图底部的页脚的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在viewDidLoad方法中设置页脚视图:

  UIView * fView = [[UIView alloc] initWithFrame:CGRectMake (0,718,239,50)]; 
fView.backgroundColor = [UIColor yellowColor];
self.table.tableFooterView = fView;

不幸的是,页脚没有绘制指定的(x,y) 以上指定,但它坚持使用单元格,因此如果表格视图有4个单元格,则页脚将在第5个单元格中绘制。



我甚至尝试了协议方法, tableView:viewForFooterInSection

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

UIView * fView = [[UIView alloc] initWithFrame:CGRectMake(0,0,239,50)];
fView.backgroundColor = [UIColor yellowColor];
返回fView;
}

问题未解决,我肯定 tableFooterView 属性应该是表视图底部的页脚视图,但我不确定我在这里可能缺少什么?提前完成。

解决方案

因为您的目标是将页脚固定在屏幕底部,而不是滚动与表,然后你不能使用表视图页脚。实际上,您甚至无法使用 UITableViewController



您必须将视图控制器实现为的UIViewController 。然后,您将自己的表视图添加为子视图。您还将页脚添加为视图控制器视图的子视图,而不是表视图。确保您调整表格视图的大小,使其底部位于页脚视图的顶部。



您需要使视图控制器符合 UITableViewDataSource UITableViewDelegate 协议并挂钩所有内容以复制 UITableViewController 的功能。 / p>

I am setting a footer view in the viewDidLoad method:

UIView *fView = [[UIView alloc] initWithFrame:CGRectMake(0, 718, 239, 50)];
fView.backgroundColor =[UIColor yellowColor];
self.table.tableFooterView = fView;

Unfortunately, the footer is not drawing in the specified (x,y) specified above, but it stick with the cells, so if the table view has 4 cells, the footer will be drawn in the 5th cell.

I even tried the protocol method, tableView:viewForFooterInSection

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

UIView *fView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 239, 50)];
fView.backgroundColor =[UIColor yellowColor];
    return fView;
}

the problem is not resolved, I am sure tableFooterView property should fi the footer view at the bottom of the table view but I am not sure what I may be missing here? Thanx in advance.

解决方案

Since your goal is to have a footer that stays fixed at the bottom of the screen, and not scroll with the table, then you can't use a table view footer. In fact, you can't even use a UITableViewController.

You must implement your view controller as a UIViewController. Then you add your own table view as a subview. You also add your footer as a subview of the view controller's view, not the table view. Make sure you size the table view so its bottom is at the top of the footer view.

You will need to make your view controller conform to the UITableViewDataSource and UITableViewDelegate protocols and hook everything up to replicate the functionality of UITableViewController.

这篇关于tableFooterView属性不会修复表视图底部的页脚的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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