ARAccordionTableView 1.0.0

ARAccordionTableView 1.0.0

Maintained by AbdulRehman Warraich.



  • By
  • AbdulRehman Warraich

ARAccordionTableView

CI Status Version License Platform

Example

Requirements

  • iOS 9.0
  • Xcode 11.2
  • Swift 5

Installation

ARAccordionTableView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ARAccordionTableView'

Then, run the following command:

pod install

How To Use?

Steps:

You can use ARAccordionTableView in simple three easy steps.

  1. Add pod in your PodFile.
  2. Change your UITableView class with ARAccordionTableView
  3. Subclass your UITableViewHeaderFooterView with ARAccordionTableViewHeaderView

Different Configuration:

  1. Open one section at any time, to achive this set following property like below.
tableView.allowMultipleSectionsOpen = false

and if you want to open multiple sections set value to true

tableView.allowMultipleSectionsOpen = true
  1. Set keepOneSectionOpen property to true to keep one section open all the time
tableView.keepOneSectionOpen = true
  1. Open specific sections on start like below.
tableView.initialOpenSections = [1,3]
  1. To check if section is open or close
let isSection = tableView.isSectionOpen(1)
  1. To toggle section use following function
tableView.toggleSection(1)
  1. To close all sections
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
}
}

Author

AbdulRehman Warraich, [email protected]

ARAccordionTableView is based on FZAccordionTableView.

License

ARAccordionTableView is released under the MIT license. See LICENSE for details.