All Projects → LaurentiuUngur → Luexpandabletableview

LaurentiuUngur / Luexpandabletableview

Licence: mit
A subclass of UITableView with expandable and collapsible sections

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Luexpandabletableview

Abexpandableview
Expandable, collapsible, filterable and single/multi selectable table view.
Stars: ✭ 138 (+10.4%)
Mutual labels:  cocoapods, pod, tableview, expandable, collapsible
Accordionswift
The best way of implement an accordion menu using an UITableView in Swift
Stars: ✭ 156 (+24.8%)
Mutual labels:  xcode, cocoapods, tableview
Parallaxheader
Simple way to add parallax header to UIScrollView/UITableView written in Swift.
Stars: ✭ 808 (+546.4%)
Mutual labels:  xcode, cocoapods, tableview
Campcotcollectionview
Collapse and expand UICollectionView sections with one method call.
Stars: ✭ 161 (+28.8%)
Mutual labels:  cocoapods, expandable, collapsible
Xcode One Dark
Atom One Dark theme for Xcode
Stars: ✭ 273 (+118.4%)
Mutual labels:  xcode, cocoapods, cocoa
Containercontroller
UI Component. This is a copy swipe-panel from app: Apple Maps, Stocks. Swift version
Stars: ✭ 273 (+118.4%)
Mutual labels:  xcode, cocoapods, tableview
Ynexpandablecell
✨ Awesome expandable, collapsible tableview cell for iOS written in Swift 4
Stars: ✭ 445 (+256%)
Mutual labels:  tableview, expandable, collapsible
Badgehub
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.
Stars: ✭ 592 (+373.6%)
Mutual labels:  xcode, cocoapods, pod
Luautocompleteview
Highly configurable autocomplete view that is attachable to any UITextField
Stars: ✭ 55 (-56%)
Mutual labels:  xcode, cocoapods, cocoa
Nim ios uikit
网易云信 iOS UI 组件,提供聊天界面,文本消息,图片消息,语音消息,视频消息,地理位置消息,自定义消息(阅后即焚)等消息示例。#推荐客户得比特币,首次推荐得0.02BTC,连续推荐得0.03BTC/单,上不封顶。点击参与https://yunxin.163.com/promotion/recommend
Stars: ✭ 1,326 (+960.8%)
Mutual labels:  cocoapods, pod
Pluggableappdelegate
!! No longer supported !! A lightweight service-oriented AppDelegate for iOS, made in Swift.
Stars: ✭ 96 (-23.2%)
Mutual labels:  xcode, cocoapods
Bettersegmentedcontrol
An easy to use, customizable replacement for UISegmentedControl & UISwitch.
Stars: ✭ 1,782 (+1325.6%)
Mutual labels:  cocoapods, cocoa
Mscircularslider
A fully-featured, powerful circular slider for iOS applications
Stars: ✭ 94 (-24.8%)
Mutual labels:  xcode, cocoapods
Swiftyattributes
A Swifty API for attributed strings
Stars: ✭ 1,303 (+942.4%)
Mutual labels:  cocoapods, cocoa
Croc
Swift emoji string parsing library
Stars: ✭ 124 (-0.8%)
Mutual labels:  xcode, cocoapods
Xmlmapper
A simple way to map XML to Objects written in Swift
Stars: ✭ 90 (-28%)
Mutual labels:  xcode, cocoapods
Nextgrowingtextview
📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
Stars: ✭ 1,540 (+1132%)
Mutual labels:  xcode, cocoapods
Swifterswift
A handy collection of more than 500 native Swift extensions to boost your productivity.
Stars: ✭ 10,706 (+8464.8%)
Mutual labels:  xcode, cocoapods
Rsformview
A Cocoapods library designed to easily create forms with multiple data entry fields
Stars: ✭ 84 (-32.8%)
Mutual labels:  cocoapods, pod
Everlayout
Reusable, downloadable, up-datable iOS layouts
Stars: ✭ 103 (-17.6%)
Mutual labels:  xcode, cocoapods

LUExpandableTableView

A subclass of UITableView with expandable and collapsible sections

Build Status Swift 5 Carthage compatible Swift Package Manager compatible Pod Version Pod Platform Pod License

Preview

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ sudo gem install cocoapods

CocoaPods 1.7.0+ is required.

To integrate LUExpandableTableView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

target '<Your Target Name>' do
    pod 'LUExpandableTableView'
end

Then, run the following command:

$ pod install

Carthage

You can use Carthage to install LUExpandableTableView by adding it to your Cartfile:

github "LaurentiuUngur/LUExpandableTableView" ~> 5.0

Then run carthage update.

If this is your first time using Carthage in the project, you'll need to go through some additional steps as explained over at Carthage.

Swift Package Manager

To integrate using Apple's Swift Package Manager, add the following as a dependency to your Package.swift:

.Package(url: "https://githubLaurentiuUngur/LUExpandableTableView", majorVersion: 5)

Here's an example of PackageDescription:

import PackageDescription

let package = Package(name: "MyApp",
    dependencies: [
        .Package(url: "https://github.com/LaurentiuUngur/LUExpandableTableView", majorVersion: 5)
    ])

Manually

If you prefer not to use either of the before mentioned dependency managers, you can integrate LUExpandableTableView into your project manually.

Usage

  • Import LUExpandableTableView into your project.
import LUExpandableTableView
  • Register a cell for an instance of LUExpandableTableView. Registered class must be a subclass of UITableViewCell. This step is not be necessary if you use storyboard.
expandableTableView.register(MyTableViewCell.self, forCellReuseIdentifier: cellReuseIdentifier)
  • Register a header for an instance of LUExpandableTableView. Registered class must be a subclass of LUExpandableTableViewSectionHeader Keep in mind that you cannot use storyboard in order to do this.
expandableTableView.register(UINib(nibName: "MyExpandableTableViewSectionHeader", bundle: Bundle.main), forHeaderFooterViewReuseIdentifier: sectionHeaderReuseIdentifier)
  • Set as data source and delegate.
expandableTableView.expandableTableViewDataSource = self
expandableTableView.expandableTableViewDelegate = self
  • Implement LUExpandableTableViewDataSource and LUExpandableTableViewDelegate protocols.
// MARK: - LUExpandableTableViewDataSource

extension ViewController: LUExpandableTableViewDataSource {
   func numberOfSections(in expandableTableView: LUExpandableTableView) -> Int {
       return 42
   }
   
   func expandableTableView(_ expandableTableView: LUExpandableTableView, numberOfRowsInSection section: Int) -> Int {
       return 3
   }
   
   func expandableTableView(_ expandableTableView: LUExpandableTableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
       guard let cell = expandableTableView.dequeueReusableCell(withIdentifier: cellReuseIdentifier) as? MyTableViewCell else {
           assertionFailure("Cell shouldn't be nil")
           return UITableViewCell()
       }
       
       cell.label.text = "Cell at row \(indexPath.row) section \(indexPath.section)"
       
       return cell
   }
   
   func expandableTableView(_ expandableTableView: LUExpandableTableView, sectionHeaderOfSection section: Int) -> LUExpandableTableViewSectionHeader {
       guard let sectionHeader = expandableTableView.dequeueReusableHeaderFooterView(withIdentifier: sectionHeaderReuseIdentifier) as? MyExpandableTableViewSectionHeader else {
           assertionFailure("Section header shouldn't be nil")
           return LUExpandableTableViewSectionHeader()
       }
       
       sectionHeader.label.text = "Section \(section)"
       
       return sectionHeader
   }
}

// MARK: - LUExpandableTableViewDelegate

extension ViewController: LUExpandableTableViewDelegate {
   func expandableTableView(_ expandableTableView: LUExpandableTableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
       /// Returning `UITableViewAutomaticDimension` value on iOS 9 will cause reloading all cells due to an iOS 9 bug with automatic dimensions
       return 50
   }
   
   func expandableTableView(_ expandableTableView: LUExpandableTableView, heightForHeaderInSection section: Int) -> CGFloat {
       /// Returning `UITableViewAutomaticDimension` value on iOS 9 will cause reloading all cells due to an iOS 9 bug with automatic dimensions
       return 69
   }
   
   // MARK: - Optional
   
   func expandableTableView(_ expandableTableView: LUExpandableTableView, didSelectRowAt indexPath: IndexPath) {
       print("Did select cell at section \(indexPath.section) row \(indexPath.row)")
   }
   
   func expandableTableView(_ expandableTableView: LUExpandableTableView, didSelectSectionHeader sectionHeader: LUExpandableTableViewSectionHeader, atSection section: Int) {
       print("Did select cection header at section \(section)")
   }
   
   func expandableTableView(_ expandableTableView: LUExpandableTableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
       print("Will display cell at section \(indexPath.section) row \(indexPath.row)")
   }
   
   func expandableTableView(_ expandableTableView: LUExpandableTableView, willDisplaySectionHeader sectionHeader: LUExpandableTableViewSectionHeader, forSection section: Int) {
       print("Will display section header for section \(section)")
   }
}

For more usage details please see example app

Issues

  • Returning UITableViewAutomaticDimension value on iOS 9 will cause reloading all cells due to an iOS 9 bug with automatic dimensions. On iOS 10 it works fine.

Requirements

  • Xcode 10.2+
  • Swift 5.0+
  • iOS 9.0+

Author

License

  • LUExpandableTableView is available under the MIT license.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].