[iPhone]如何自定义分组TableView中Section的标题?

发布于 2024-08-17 10:44:45 字数 182 浏览 4 评论 0原文

为了自定义单元格,我们实现了继承 UITableViewCell 的类。现在,要自定义分组UITableView中Section的标题(与下图相同),该怎么做?请指导我!
替代文字

To customize cell, we implement class inherit UITableViewCell. Now, to customize header of Section in grouped UITableView (same to below picture), how to do? Please guide to me!
alt text

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

关于从前 2024-08-24 10:44:45

在表视图委托中实现 tableView:viewForHeaderInSection:

Implement tableView:viewForHeaderInSection: in your table view delegate.

忆悲凉 2024-08-24 10:44:45

从 iOS 5 开始,您还需要实现

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

“除了”以外的其他功能

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

,否则它将无法工作。

来自 Apple 的参考

返回的对象可以是 UILabel 或 UIImageView 对象,以及自定义视图。此方法仅在 tableView:heightForHeaderInSection: 也实现时才能正确工作。

Starting with iOS 5 you also need to implement

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section

In addition to

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

Otherwise it won't work.

From Apple's reference

The returned object can be a UILabel or UIImageView object, as well as a custom view. This method only works correctly when tableView:heightForHeaderInSection: is also implemented.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文