以编程方式向UITableview添加标头

编程入门 行业动态 更新时间:2024-10-26 10:35:49
本文介绍了以编程方式向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添加标头

本文发布于:2023-11-12 18:44:15,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1582243.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式   UITableview

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!