Latest 0.8
Homepage https://github.com/NSSimpleApps/DropDownTableView
License MIT
Platforms ios 8.0, requires ARC
Authors

Supporting Swift 2.* has been removed.

>= 0.7 for Swift 3.

Place into Podfile:

pod 'DropDownTableView/Swift' # for swift project
pod 'DropDownTableView/ObjC' # for objc project

Place this preamble import DropDownTableView into source file.

Inherit from DropDownTableViewController and override methods from DropDownTableViewDataSource and DropDownTableViewDelegate.

Usage:

class TableViewController: DropDownTableViewController {
    override func numberOfRows(in tableView: UITableView) -> Int {
        return someValue
    }
    override func tableView(_ tableView: UITableView, numberOfSubrowsInRow row: Int) -> Int {
        return someValue
    }
    override var showSubrowsInRow: Int? {
        return someValue
    }
    override func tableView(_ tableView: UITableView, cellForRow row: Int, indexPath: IndexPath) -> UITableViewCell {
        if row == self.nsk_selectedRow {
            someCell.accessoryView = UIImageView(image: UIImage(named: "up_arrow"))
        } else {
            someCell.accessoryView = UIImageView(image: UIImage(named: "down_arrow"))
        }
        return someCell
    }
    override func tableView(_ tableView: UITableView, cellForSubrow subrow: Int, inRow row: Int, indexPath: IndexPath) -> UITableViewCell {
        return someCell
    }
    override func tableView(_ tableView: UITableView, didSelectRow row: Int) {
        switch (self.nsk_selectedRow, row) {
            case (let sr?, _) where row == sr:
                tableView.cellForRow(at: row)?.accessoryView =  UIImageView(image: UIImage(named: "down_arrow"))
                tableView.deselect(row: row, animated: true)
            break
            case (let sr?, _) where row != sr:
                tableView.cellForRow(at: row)?.accessoryView = UIImageView(image: UIImage(named: "up_arrow"))
                tableView.cellForRow(at: sr)?.accessoryView = UIImageView(image: UIImage(named: "down_arrow"))
            break
            case (nil, _):
                tableView.cellForRow(at: row)?.accessoryView = UIImageView(image: UIImage(named: "up_arrow"))
            break
            default:
            break
        }
        super.tableView(tableView, didSelectRow: row)
    }
}

Alt text

Latest podspec

{
    "name": "DropDownTableView",
    "version": "0.8",
    "summary": "This is a simple drop down table view.",
    "description": "DropDownTableViewController is a simple UITableViewController. Inherit from DropDownTableViewController and override methods from DropDownTableViewDataSource and DropDownTableViewDelegate.",
    "homepage": "https://github.com/NSSimpleApps/DropDownTableView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "NSSimpleApps, Sergey Poluyanov": "[email protected]"
    },
    "source": {
        "git": "https://github.com/NSSimpleApps/DropDownTableView.git",
        "tag": "0.8"
    },
    "requires_arc": true,
    "platforms": {
        "ios": "8.0"
    },
    "default_subspecs": "Swift",
    "pushed_with_swift_version": "3.0.2",
    "subspecs": [
        {
            "name": "ObjC",
            "platforms": {
                "ios": "8.0"
            },
            "source_files": "Source/ObjC/*.{h,m}",
            "public_header_files": [
                "Source/ObjC/DropDownTableView.h",
                "Source/ObjC/DropDownTableViewController.h",
                "Source/ObjC/DropDownTableViewDataSource.h",
                "Source/ObjC/DropDownTableViewDelegate.h",
                "Source/ObjC/NSIndexPath+DropDown.h",
                "Source/ObjC/UITableView+DropDown.h"
            ]
        },
        {
            "name": "Swift",
            "platforms": {
                "ios": "8.0"
            },
            "source_files": "Source/Swift/*.swift"
        }
    ]
}

Pin It on Pinterest

Share This