UItableview变量节标题高度和内容

时间:2012-10-19 17:42:34

标签: objective-c ios uitableview

是否有人知道如何创建具有可变高度部分标题和内容的UITableView,类似于Facebook iPhone应用程序?

所以我想要一些标题包含文字(例如收藏夹,应用程序等等)。但是有些节标题我只想要没有文字而是5像素高的分隔符(例如在Facebook Messenger应用程序分隔符中)。

示例:

FAVORITES <-- Header:
 fav1
 fav2
 fav3

APPS   <-- Header: this is all apps header
 app1  <-- these are the most used apps
 app2
=====  <-- Header: this is a header with no text (see Facebook Messenger)
 app3  <-- apps not used in a long time
 app4

FRIENDS <-- Header:
 Sam
 Tina 

所以我需要部分标题的动态内容。这些部分每次都需要按一定的顺序排列。最后,节头必须具有一定的高度。

1 个答案:

答案 0 :(得分:2)

您需要引用UITableViewDelegate和UITableViewDatasource文档。

具体来说这两种方法:

– tableView:heightForHeaderInSection:

- tableView:viewForHeaderInSection: