以编程方式向UITableview添加标头 [英] Adding a header to UITableview programmatically
本文介绍了以编程方式向UITableview添加标头的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何以编程方式添加此功能?我不确定我会搜索到什么。我知道如何添加IBAction而不是代码来生成图片中突出显示的此功能。它是自定义单元格还是分隔符?
解决方案
这只是TableView中的标题,它们出现在如果你想要一个标题,请使用此方法:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
或这个如果你想要一个自定义视图:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)部分
高度:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
How would I add this feature programmatically? I'm not sure what I would search to find this. I know how to add the IBAction but not the code to generate this feature highlighted in the picture. Is it a custom cell or a divider?s
解决方案
That's just a header in the TableView, they appear on top of your section
Use this method if you want a title:
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section
Or this one if you want a custom view:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
And for the height:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
这篇关于以编程方式向UITableview添加标头的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文