Skip to content
 
 

Latest commit

 

History

224 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

QuickTableViewController

Build Status Carthage compatible CocoaPods Compatible Platform CocoaDocs codecov.io Swift 3.0

A simple way to create a table view for settings, providing table view cells with:

  • UISwitch
  • Center aligned text
  • Table view cell image
  • Disclosure indicator
  • Specified UITableViewCellStyle

Usage

Set up tableContents in viewDidLoad:

import QuickTableViewController

class ViewController: QuickTableViewController {

  override func viewDidLoad() {
    super.viewDidLoad()

    tableContents = [
      Section(title: "Switch", rows: [
        SwitchRow(title: "Setting 1", switchValue: true, action: { _ in }),
        SwitchRow(title: "Setting 2", switchValue: false, action: { _ in }),
      ]),

      Section(title: "Tap Action", rows: [
        TapActionRow(title: "Tap action", action: showAlert)
      ]),

      Section(title: "Cell Styles", rows: [
        NavigationRow(title: "CellStyle.Default", subtitle: .None, icon: Icon(image: UIImage(named: "exit"), highlightedImage: UIImage(named: "exit-highlighted"))),
        NavigationRow(title: "CellStyle", subtitle: .BelowTitle(".Subtitle"), icon: Icon(image: UIImage(named: "language"))),
        NavigationRow(title: "CellStyle", subtitle: .RightAligned(".Value1"), icon: Icon(imageName: "timeMachine"), action: showDetail),
        NavigationRow(title: "CellStyle", subtitle: .LeftAligned(".Value2"))
      ])
    ]
  }

  // MARK: - Actions

  private func showAlert(_ sender: Row) {
    // ...
  }

  private func showDetail(_ sender: Row) {
    // ...
  }

}

NavigationRow

Subtitle Styles

NavigationRow(title: "UITableViewCellStyle.Default", subtitle: .None)
NavigationRow(title: "UITableViewCellStyle", subtitle: .BelowTitle(".Subtitle")
NavigationRow(title: "UITableViewCellStyle", subtitle: .RightAligned(".Value1")
NavigationRow(title: "UITableViewCellStyle", subtitle: .LeftAligned(".Value2"))

IconEnabled

  • Images in table view cells can be set by specifying the icon of each IconEnabled row.
  • The Icon struct carries info about images for both normal and highlighted states.
  • Table view cells in UITableViewCellStyle.Value2 will hide images.
NavigationRow(title: "Cell with image", subtitle: .None, icon: Icon(imageName: "icon"))

Disclosure Indicator

  • A NavigationRow with an action will be displayed in a table view cell whose accessoryType is .DisclosureIndicator.
  • The action will be invoked when the related table view cell is selected.
NavigationRow(title: "Navigation cell", subtitle: .None, action: { (sender: Row) in })

SwitchRow

  • A SwitchRow is associated to a table view cell with a UISwitch as its accessoryView.
  • The optional action will be invoked when the switchValue changes.
  • It also conforms to IconEnabled.
SwitchRow(title: "Switch", switchValue: true, action: { (sender: Row) in }),

The original SwitchRow in the tableContents will be replaced by an updated one after the switchValue changed.

TapActionRow

  • A TapActionRow is associated to a button-like table view cell.
  • The action will be invoked when the related table view cell is selected.
TapActionRow(title: "Tap action", action: { (sender: Row) in })

Use Custom Cell Classes

// NavigationRow
tableView.register(CustomCell.self, forCellReuseIdentifier: "Subtitle.None")
tableView.register(CustomSubtitleCell.self, forCellReuseIdentifier: "Subtitle.BelowTitle")
tableView.register(CustomValue1StyleCell.self, forCellReuseIdentifier: "Subtitle.RightAligned")
tableView.register(CustomValue2StyleCell.self, forCellReuseIdentifier: "Subtitle.LeftAligned")

// SwitchRow
tableView.register(CustomSwitchCell.self, forCellReuseIdentifier: "SwitchCell")

// TapActionRow
tableView.register(CustomTapActionCell.self, forCellReuseIdentifier: "TapActionCell")

Full Documentation

https://bcylin.github.io/QuickTableViewController

Requirements

QuickTableViewController iOS Xcode Swift
~> 0.1.0 8.0+ 6.4 Swift 1.2
~> 0.2.0 8.0+ 7.0 Swift 2.0
~> 0.3.0 8.0+ 7.3 Swift 2.2
~> 0.4.0 8.0+ 8.0 Swift 2.3
~> 0.5.0 8.0+ 8.0 Swift 3.0

Installation

Create a Podfile with the following specification and run pod install.

platform :ios, '8.0'
use_frameworks!

pod 'QuickTableViewController', '~> 0.5.0'

Create a Cartfile with the following specification and run carthage update QuickTableViewController. Follow the instructions to add the framework to your project.

github "bcylin/QuickTableViewController" ~> 0.5.0

Use Git Submodule

git submodule add -b master git@github.com:bcylin/QuickTableViewController.git Dependencies/QuickTableViewController
  • Drag QuickTableViewController.xcodeproj to your app project as a subproject.
  • On your application target's Build Phases settings tab, add QuickTableViewController-iOS to Target Dependencies.

Contact

Twitter

License

QuickTableViewController is released under the MIT license. See LICENSE for more details. Image source: iconmonstr.

About

A simple way to create a UITableView for settings in Swift.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages