gpt4 book ai didi

cocoa-touch - InterfaceBuilder 中的 UITableViewHeaderFooterView

转载 作者:行者123 更新时间:2023-12-03 07:53:54 24 4
gpt4 key购买 nike

我想使用 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/

    24 4 0
    Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
    广告合作:1813099741@qq.com 6ren.com