cocoa-touch - InterfaceBuilder 中的 UITableViewHeaderFooterView

标签 cocoa-touch uitableview

我想使用 IB 在单独的 .xib 中创建自定义标题部分 View

但是在 IB 中我找不到组件 UITableViewHeaderFooterView(类似于 UITableViewCell)并为其分配重用

那么如何在自定义标题部分中创建?

我创建了一个继承自 UITableViewHeaderFooterView 的类 MySection
创建一个 .xib,MySection.xib
注册 xib 以进行单元重用

问题是,如何使用 initWitReuseIdentifier....

最佳答案

我写了一个guide (在 iOS 9 上测试),包括 4 个步骤:

  • 子类 UITableViewHeaderFooterView
  • 使用子类 View 创建 Nib,并在页眉/页脚中添加 1 个包含所有其他 View 的容器 View
  • viewDidLoad , 调用registerNib:forHeaderFooterViewReuseIdentifier:用于表格 View
  • 实现viewForHeaderInSection并使用 dequeueReusableHeaderFooterViewWithIdentifier取回页眉/页脚
  • 关于cocoa-touch - InterfaceBuilder 中的 UITableViewHeaderFooterView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17651880/

    相关文章:

    ios - uilabel 上的罢工消失在 uitableview 中是否选择了单元格

    ios - UITableViewCell 内的 UIView 转换不起作用

    ios - swift ios 8 在表格 View 中更改部分的字体标题

    objective-c - 检查一个 NSArray 的内容是否都在另一个数组中

    objective-c - EXC_BAD_ACCESS在 block “回调”上

    iPhone - 调试 EXC_BAD_ACCESS 崩溃

    ios - 如何添加动态部分但仍然只添加到其中一个部分?

    ios - 使用 XIB 自定义 UITableViewCell

    objective-c - 旋转后移动图像的行为不正确

    ios - 将参数传递给@selector 方法