ARAccordionTableView 1.0.0

ARAccordionTableView 1.0.0

AbdulRehman Warraich 维护。



  • 作者
  • AbdulRehman Warraich

ARAccordionTableView

CI Status Version License Platform

示例

要求

  • iOS 9.0
  • Xcode 11.2
  • Swift 5

安装

ARAccordionTableView 可通过 CocoaPods 获取。要安装它,只需将以下行添加到您的 Podfile 中

pod 'ARAccordionTableView'

然后,运行以下命令

pod install

如何使用?

步骤

您可以使用ARAccordionTableView通过三个简单的步骤。

  1. 在您的PodFile中添加pod。
  2. 将您的UITableView类替换为ARAccordionTableView
  3. 将您的UITableViewHeaderFooterView类继承自ARAccordionTableViewHeaderView

不同的配置

  1. 在任何时候打开一个部分,为了实现这一点,设置以下属性。
tableView.allowMultipleSectionsOpen = false

如果您想同时打开多个部分,将值设置为true

tableView.allowMultipleSectionsOpen = true
  1. 设置keepOneSectionOpen属性为true以始终打开一个部分
tableView.keepOneSectionOpen = true
  1. 如下所示在启动时打开特定部分。
tableView.initialOpenSections = [1,3]
  1. 检查部分是否打开或关闭
let isSection = tableView.isSectionOpen(1)
  1. 要切换部分,请使用以下函数
tableView.toggleSection(1)
  1. 要关闭所有部分
tableView.closeAllSections()

ARAccordionTableViewDelegate

extension ViewController : ARAccordionTableViewDelegate {

func tableView(_ tableView: ARAccordionTableView, canInteractWithHeaderAtSection section: Int) -> Bool {
//Return whether user can interact with header View
return true
}

func tableView(_ tableView: ARAccordionTableView, willOpenSection section: Int, withHeader header: UITableViewHeaderFooterView?) {

// called before section is opening
}

func tableView(_ tableView: ARAccordionTableView, didOpenSection section: Int, withHeader header: UITableViewHeaderFooterView?) {
// called after section opened
}

func tableView(_ tableView: ARAccordionTableView, willCloseSection section: Int, withHeader header: UITableViewHeaderFooterView?) {
// called before section closes
}

func tableView(_ tableView: ARAccordionTableView, didCloseSection section: Int, withHeader header: UITableViewHeaderFooterView?) {
// called after section closed
}

func tableView(_ tableView: ARAccordionTableView, didLogPressedSection section: Int, withHeader header: UITableViewHeaderFooterView?, longPressGestureState state: UIGestureRecognizer.State) {

// called when user long press on a tableView header
}
}

作者

AbdulRehman Warraich,[email protected]

ARAccordionTableView基于FZAccordionTableView

许可证

ARAccordionTableView按照MIT许可证发布。查看LICENSE获取详细信息。