ios – 如何使用XIB自定义tableView Section Header?

前端之家收集整理的这篇文章主要介绍了ios – 如何使用XIB自定义tableView Section Header?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试为UITableView创建自定义的节标题.我找到了一些参考资料,说明如何在代码中完成这项工作(# 1349571).

我试图确定是否可以在Interface Builder中创建UIView并使用它来自定义标题,类似于如何为UITableViewCell执行此操作?

解决方法

是可以使用使用XIB创建的标题视图.创建一个XIB和类来管理XIB(UIView类).使用
YourNibClassName* v = [[[NSBundle mainBundle] loadNibNamed:@"YOUR_XIB_NAME" owner:self options:nil] firstObject];

//With this method you can load any xib for header view

tableView.tableHeaderView = v;
[v release];

编辑

像这样在viewForHeaderInSection中返回此视图

YourNibClassName* v = [[[NSBundle mainBundle] loadNibNamed:@"YOUR_XIB_NAME" owner:self options:nil] firstObject];
//Do some stuff here like setting text on labels etc.
return [v autorelease];
原文链接:https://www.f2er.com/iOS/329047.html

猜你在找的iOS相关文章