Skip to content

Repository files navigation

QuickTableViewController

Carthage compatibleBuild Statuscodecov.io

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
classViewController:QuickTableViewController{overridefunc 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
privatefunc showAlert(sender:Row){
// ...
}privatefunc 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"))

Image View

  • Images in table view cells can be set by specifying icon of each NavigationRow.
  • 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.
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})

Requirements

  • v0.1 requires Swift 1.2 and iOS 8.0+ with Xcode 6.4.
  • v0.2 is now in Swift 2 with Xcode 7.0 or above.

Installation

Install via Carthage

  • Create a Cartfile with the following specification and run carthage bootstrap.

    github "bcylin/QuickTableViewController"
    
  • On your application targets' General settings tab, in the Linked Frameworks and Libraries section, drag and drop QuickTableViewController.framework from the Carthage/Build folder.

  • On your application targets’ Build Phases settings tab, click the + icon and choose New Run Script Phase. Create a Run Script with the following contents:

    /usr/local/bin/carthage copy-frameworks
    

    and add the following path to Input Files:

    $(SRCROOT)/Carthage/Build/iOS/QuickTableViewController.framework
    
  • For more information, please check out the Carthage Documentation.

Install via CocoaPods

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

    platform:ios,'8.0'use_frameworks!pod'QuickTableViewController',git: 'https://github.com/bcylin/QuickTableViewController.git'

Install Manually

  • Copy *.swift files in the Source directory to an iOS project.

License

QuickTableViewController is released under the MIT license. See LICENSE for more info.

About

A simple way to create a table view for settings in Swift.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages