修复了UITableview的标题? [英] Fixed header to UITableview?

查看:119
本文介绍了修复了UITableview的标题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UITableView ,我想在其上添加44px子视图。我尝试了 tableViewHeader ,但是滚动了表格的其余部分。

I've got a UITableView that I'd like to stick a 44px subview on top of. I tried tableViewHeader, but that scrolls with the rest of the table.

我试过搜索并找到了很多人说我需要添加一个UIView超级视图,然后将我的标题和UITableView添加到它。但是我找不到一个关于如何做到这一点的例子。我尝试创建一个新的UIView子类并在IB中布置子视图,但是我遇到了让桌面控制器与UITable链接的问题(因为我对IB知之甚少)。

I tried searching and have found many people saying I need to add a UIView superview and then add my header and the UITableView to it. However I can't find an example on exactly how to do this. I tried making a new UIView subclass and laying out the subviews in IB, but I ran into trouble getting the table controller to link w/ the UITable (because I don't know enough about IB).

如何使用XIB 执行此操作?有人可以提供一个例子吗?

How can I do this with XIBs? Can someone provide an example?

感谢你们提供的任何帮助。

Thanks for any help you guys can provide.

推荐答案

我终于在发布后想出了这个。人物。 :)

I finally figured this out right after posting. Figures. :)

这是我做的,以防其他人遇到同样的问题:

Here's what I did, in case others run into the same problem:


  1. 删除现有的 UITableViewController 及其XIB。他们是垃圾。在你这么做的时候真的很生气。

  1. Delete the existing UITableViewController and its XIB. They're junk. Get really mad while you do.

用XIB创建一个新的 UIViewController 子类

Make a new UIViewController subclass with a XIB

在IB中打开XIB并将您的标题内容和 UITableView 添加到 UIView

Open XIB in IB and add your header stuff and a UITableView to the UIView

UITableView 的I​​B Outlets中,确保将Delegate和DataSource连接到您的文件所有者

In the IB Outlets for UITableView make sure you connect Delegate and DataSource to your File Owner

在视图控制器的标题中,请务必添加< UITableViewDelegate,UITableViewDataSource> 实现这些协议

In the header for your view controller, be sure to add <UITableViewDelegate, UITableViewDataSource> to implement these protocols

实现你知道的所有常规 UITableView 委托和数据源方法爱,但在你的 UIViewController 而不是你习惯的方式通过 UITableViewController

Implement all the regular UITableView delegate and data source methods you know and love, but in your UIViewController instead of the way you're used to doing it through UITableViewController

此后事情应该有效。

这篇关于修复了UITableview的标题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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