FUIValuePickerFormCell

@IBDesignable
open class FUIValuePickerFormCell : FUIInlineValidationTableViewCell, FUIPropertyFormCell, UIPickerViewDataSource, UIPickerViewDelegate

A customized UITableViewCell, which contains a UILabel, a UITextField and a UIPickerView. It allows users to select a single value from a set of options using a spinning wheel.

FUIValuePickerFormCell

The developer should set the following properties on the cell, in their implementation of UITableViewDataSource cellForRow(at:) function:

  • keyName: The key name of the property
  • valueOptions: A set of options that users can chose from.
  • value: The value of the property, as Int

And an onChangeHandler:

  • onChangeHandler: a handler closure, which is invoked on changes to the value.

Optionally, the developer may set

  • isEditable: Indicates if the cell’s value may be modified. Defaults to true.

Color setting:

Setting text color of filter buttons for a state using setTintColor(_:for:) api. Currently .disabled, .normal and selected are supported.

cell.setTintColor(UIColor.red, for: .normal)

The following is an example of usage in an application UITableViewController:

Important

The app’s UITableViewController must subclass FUIFormTableViewController
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(FUIValuePickerFormCell, forCellReuseIdentifier: FUIValuePickerFormCell.reuseIdentifier)
// ...
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

let cell = tableView.dequeueReusableCell(withIdentifier: FUIValuePickerFormCell.reuseIdentifier, for: indexPath) as! FUIValuePickerFormCell
cell.keyName = "Maximum Price"
cell.valueOptions = ["5", "10", "15", "20", "25"]
cell.value = 0

// MARK:  implement an onChangeHandler
cell.onChangeHandler = { [weak self] newValue in
self.myObject.price = self.priceTitles[newValue].first!.key
}

return cell
}

Theming

Supported style classes

fdlFUIValuePickerFormCell
fdlFUIValuePickerFormCell_keyLabel
fdlFUIValuePickerFormCell_valueTextField
fdlFUIValuePickerFormCell_valueTextField_selected
  • The UILabel holds the key name string.

    Declaration

    Swift

    @IBOutlet
    public private(set) weak var keyLabel: UILabel! { get }
  • The UITextField holds the selected value strings.

    Declaration

    Swift

    @IBOutlet
    public private(set) weak var valueTextField: UITextField! { get }
  • The array of the valid options.

    Declaration

    Swift

    public var valueOptions: [String] { get set }
  • The default cell reuse identifier.

    Declaration

    Swift

    open class var reuseIdentifier: String { get }
  • The value type is Int.

    Declaration

    Swift

    public typealias ValueType = Int
  • The value of the cell.

    Declaration

    Swift

    public var value: Int { get set }
  • Implementation of change handler. Is invoked on changes to the value property.

    Declaration

    Swift

    public var onChangeHandler: ((Int) -> Void)?
  • Indicates if the value of the cell may be modified. Default value is true.

    Declaration

    Swift

    public var isEditable: Bool { get set }
  • Indicate whether the picker is enabled. isEnabled and isEditable are in sync.

    Declaration

    Swift

    override public var isEnabled: Bool { get set }
  • If isTrackingLiveChanges is true, then onChangeHandler, will be invoked whenever a value is selected.

    Otherwise, onChangeHandler will be invoked only when the Value Picker is closed.

    The default value is true.

    Declaration

    Swift

    public var isTrackingLiveChanges: Bool
  • This property indicates whether the picker is to always be displayed.

    The default is false.

    Declaration

    Swift

    open var alwaysShowPicker: Bool { get set }
  • The key name of the cell.

    Declaration

    Swift

    @IBInspectable
    public var keyName: String? { get set }