{"id":2898,"url":"https://github.com/jeantimex/CollapsibleTableSectionViewController","last_synced_at":"2025-08-06T16:32:04.873Z","repository":{"id":51808535,"uuid":"97889347","full_name":"jeantimex/CollapsibleTableSectionViewController","owner":"jeantimex","description":":tada: Swift library to support collapsible sections in a table view.","archived":false,"fork":false,"pushed_at":"2021-05-09T21:36:12.000Z","size":2328,"stargazers_count":352,"open_issues_count":15,"forks_count":52,"subscribers_count":14,"default_branch":"master","last_synced_at":"2024-10-29T20:22:30.161Z","etag":null,"topics":["cocoapod","collapsible-sections","ios-swift","swift-4-2","uitableviewcontroller"],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jeantimex.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-07-21T00:29:50.000Z","updated_at":"2024-04-21T08:22:16.000Z","dependencies_parsed_at":"2022-08-21T03:20:46.696Z","dependency_job_id":null,"html_url":"https://github.com/jeantimex/CollapsibleTableSectionViewController","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeantimex%2FCollapsibleTableSectionViewController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeantimex%2FCollapsibleTableSectionViewController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeantimex%2FCollapsibleTableSectionViewController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jeantimex%2FCollapsibleTableSectionViewController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jeantimex","download_url":"https://codeload.github.com/jeantimex/CollapsibleTableSectionViewController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228923736,"owners_count":17992570,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapod","collapsible-sections","ios-swift","swift-4-2","uitableviewcontroller"],"created_at":"2024-01-05T20:16:25.773Z","updated_at":"2024-12-09T16:31:14.901Z","avatar_url":"https://github.com/jeantimex.png","language":"Swift","funding_links":["https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=BFXQGY77CV3T2"],"categories":["UI","Libs","UI [🔝](#readme)"],"sub_categories":["Table View / Collection View","UI","Other free courses"],"readme":"# CollapsibleTableSectionViewController\n\n[![Platform](https://img.shields.io/badge/platform-ios-blue.svg?style=flat)]()\n[![Swift 4.2](https://img.shields.io/badge/Swift-4.2-orange.svg?style=flat)](https://developer.apple.com/swift/)\n[![CocoaPods](https://img.shields.io/cocoapods/v/CollapsibleTableSectionViewController.svg)](https://cocoapods.org/pods/CollapsibleTableSectionViewController)\n[![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![Build](https://travis-ci.org/jeantimex/CollapsibleTableSectionViewController.svg?branch=master)](https://travis-ci.org/jeantimex/CollapsibleTableSectionViewController)\n[![codecov.io](https://codecov.io/github/jeantimex/CollapsibleTableSectionViewController/badge.svg?branch=master)](https://codecov.io/github/jeantimex/CollapsibleTableSectionViewController?branch=master)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat)](LICENSE)\n[![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick\u0026hosted_button_id=BFXQGY77CV3T2)\n\nA Swift library that helps you collapse table view sections.\n\n![cover](https://user-images.githubusercontent.com/565300/33296447-99433820-d390-11e7-8d05-bcac316e896a.gif)\n\n## Features\n\n- Support collapsible sections in a table view\n- Collapse all the sections by default (configurable)\n- Keep only one section expanded (configurable)\n- Auto resize table view cell\n- Easy-to-use protocols for configuration\n\n## Requirements\n\n- iOS 9.0+\n- Xcode 10.0+\n- Swift 4.2\n\n## Installation\n\n### Manual\n\nJust clone and add the following Swift files to your project:\n- CollapsibleTableSectionViewController.swfit\n- CollapsibleTableViewHeader.swift\n\n### Cocoapods\n\n- Make sure that you use latest stable Cocoapods version: `pod --version`\n- If not, update it: `sudo gem install cocoapods`\n- `pod init` in you project root dir\n- `nano Podfile`, add:\n```\nuse_frameworks! \npod 'CollapsibleTableSectionViewController', '~\u003e 2.0.1'\n``` \n- Save it: `ctrl-x`, `y`, `enter`\n- `pod update`\n- Open generated `.xcworkspace`\n- Don't forget to import CollapsibleTableSectionViewController: `import CollapsibleTableSectionViewController`!\n\n### Carthage\n\n* `nano Cartfile`\n* put `github \"jeantimex/CollapsibleTableSectionViewController\" ~\u003e 2.0.1` into Cartfile\n* Save it: `ctrl-x`, `y`, `enter`\n* Run `carthage update`\n* Copy `CollapsibleTableSectionViewController.framework` from `Carthage/Build/iOS` to your project\n* Make sure that `CollapsibleTableSectionViewController` is added in `Embedded Binaries` section of your target (or else you will get `dyld library not loaded referenced from ... reason image not found` error)\n* Add `import CollapsibleTableSectionViewController` on top of your view controller's code\n\n## Usage\n\n#### Step 1. Subclass `CollapsibleTableSectionViewController`\n\n```swift \nimport CollapsibleTableSectionViewController\n\nclass ViewController: CollapsibleTableSectionViewController { ... }\n```\n\n#### Step 2. Conforms to the `CollapsibleTableSectionDelegate` protocol\n\n```swift\nextension ViewController: CollapsibleTableSectionDelegate { ... }\n```\n\n## CollapsibleTableSectionDelegate Protocol\n\nMost of the protocol methods are optional and they are very similar to `UITableViewDataSource` and `UITableViewDelegate`, here is a list of the available protocol methods:\n\n#### 1. optional func numberOfSections(_ tableView: UITableView) -\u003e Int\nAsks the data source to return the number of sections in the table view. Default is `1`.\n\n```swift\nextension ViewController: CollapsibleTableSectionDelegate {\n  func numberOfSections(_ tableView: UITableView) -\u003e Int {\n    return 10\n  }\n}\n```\n\n#### 2. optional func collapsibleTableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -\u003e Int\nReturns the number of rows (table cells) in a specified section. Default is `0`.\n\n```swift\nextension ViewController: CollapsibleTableSectionDelegate {\n  func collapsibleTableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -\u003e Int {\n    return 5\n  }\n}\n```\n\n#### 3. optional func collapsibleTableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -\u003e UITableViewCell\n\nReturns the table cell at the specified index path. You can also use your custom cells, see our example projects for more details.\n\n```swift\nextension ViewController: CollapsibleTableSectionDelegate {\n  func collapsibleTableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -\u003e UITableViewCell {\n    let cell = tableView.dequeueReusableCell(withIdentifier: \"Cell\") as UITableViewCell? ?? UITableViewCell(style: .default, reuseIdentifier: \"Cell\")\n    cell.textLabel?.text = \"Cell Text\"\n    return cell\n  }\n}\n```\n\n#### 4. optional func shouldCollapseByDefault(_ tableView: UITableView) -\u003e Bool\n\nReturn `true` if you would like collapse all the sections when the table is loaded. Default is `false`.\n\n#### 5. optional func shouldCollapseOthers(_ tableView: UITableView) -\u003e Bool\n\nReturn `true` if you would like to keep only one extended section (like accordion style). Default is `false`.\n\n#### 6. optional func collapsibleTableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -\u003e String?\n\nThe title for each section. Default is `nil`.\n\n#### 7. optional func collapsibleTableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath)\n\nTells the delegate that the specified row is now selected.\n\n## Examples\n\nRun the Examples project in this repo and you will find the following demos that help you get up and running:\n\n1. Basic: The minimal working example\n2. Custom Cell: Implement a custom cell programmatically\n3. Collapse By Default: All sections are collapsed by default\n4. Collapse Others: Accordion-style table view that only keeps one section expanded at a time\n\nFor more details of how to implement collapsible table sections using Swift, please checkout this repo for more information: https://github.com/jeantimex/ios-swift-collapsible-table-section.\n\n## Contribution\n\nAnyone who would like to contribute to the project is more than welcome.\n\n* Fork this repo\n* Make your changes\n* Submit pull request\n\n## License\n\nMIT License\n\nCopyright (c) 2017 Yong Su @jeantimex\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeantimex%2FCollapsibleTableSectionViewController","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjeantimex%2FCollapsibleTableSectionViewController","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjeantimex%2FCollapsibleTableSectionViewController/lists"}