本文介绍了以编程方式向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)sectionOr this one if you want a custom view:
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)sectionAnd for the height:
- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
更多推荐
以编程方式向UITableview添加标头
发布评论