开发者

How to mix "Custom Section Header View(s)" and "Regular Header(s)" in a UITableViewController?

Imagine a table ("StyleGrouped") with multiple sections:

  • Some sections should have a "regular header title".
  • There should be some buttons, between the "regular sections".

Intuitively, in order to define the section titles, I would use:

(NSString *)tableView:(开发者_运维百科UITableView *)tableView titleForHeaderInSection:(NSInteger)section

And in order to simulate the buttons, I would create custom UIViews via:

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

The problem is that by the time you start using viewForHeaderInSection, then titleForHeaderInSection stops working...

It makes sense somehow since we're now supposed to provide custom header views. The only problem is that there is no way to access the original UIView used by UIKit to render "regular header titles"...

Not the end of the world (i.e. creating your own UILabel and simulating the UIKit look & feel) but I'm just wondering if I missed something (?)


It appears that viewForHeaderInSection gets called before titleForHeaderInSection. However if you do return nil for a specific row where you don't want to use a view, the titleForHeaderInSection is called.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜