Melodeon 0.1.4

Melodeon 0.1.4

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2017
SwiftSwift Version 3.0.2
SPMSupports SPM

Maintained by Chad.



Melodeon 0.1.4

  • By
  • chaddgrimm

A simple subclass of UITableViewController which behaves like a melodeon.

Screen capture

Usage

Inherit MelodeonController and implement it just like you would on a normal UITableViewController.

  class TableViewController: MelodeonController {
    var firstList = ["Option One", "Option Two", "Option Three"]
    var secondList = ["Choice One", "Choice Two", "Choice Three", "Choice Four" ]
    var thirdList = ["Element One", "Element Two"]
   
    ...
    .....
    
  }

Provide your sections as array and override the sections property.

  override var sections:[Any] {
    return ["List A", "List B", "List C"]
  }

And provide the number of rows per section (this is required).

  override func numberOfRows(inSection section:Int) -> Int {
    switch section {
    case 0:
      return firstList.count
    case 1:
      return secondList.count
    case 2:
      return thirdList.count
    default:
      return 0
    }
  }
  

Optional:

You may implement your own header cell as long as it is of type MelodeonHeaderCell.

  override var headerClasses:[MelodeonHeaderCell.Type]? {
    return [TableHeaderCell.self, AnotherHeaderCell.self]
  }

You may also provide the section which will be expanded when the view is loaded.

  override var initialExpandedSection: Int {
    return 0
  }

You can control which header is interactive.

  override func header(_ header: MelodeonHeaderCell, shouldTapAtSection section: Int) -> Bool {
    if section == 1 {
      return false
    }
    return true
  }

Or handle the tap events.

  override func header(_ header: MelodeonHeaderCell, didTapAtSection section: Int) {
    // TODO: Implement header tap event here
  }

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

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

pod "Melodeon"

Author

Chad Lee, [email protected]

License

Melodeon is available under the MIT license. See the LICENSE file for more info.