FUISimplePropertyFormCell

open class FUISimplePropertyFormCell: FUIInlineValidationTableViewCell, FUIPropertyFormCell

The reusable UI component implemented as an UITableViewCell to display or edit a key-value pair property.

FUISimplePropertyFormCell

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.
  • value: The value of the property.

And an onChangeHandler:

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

Optionally, the developer may provide

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

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(FUISimplePropertyFormCell.self, forCellReuseIdentifier: FUISimplePropertyFormCell.reuseIdentifier)
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: FUISimplePropertyFormCell.reuseIdentifier, for: indexPath) as! FUISimplePropertyFormCell

    cell.keyName = "Editable"
    cell.value = myObject.productName

    // MARK:  implement onChangeHandler
    cell.onChangeHandler = { newValue in
        myObject.productName = newValue
    }

    return cell
}
  • The value type is String.

    Declaration

    Swift

    public typealias ValueType = String
  • The default cell reuse identifier.

    Declaration

    Swift

    open static var reuseIdentifier: String
  • The value of the property.

    Declaration

    Swift

    open var value: String
  • Implementation of change handler. Is invoked on changes to the value property.

    Declaration

    Swift

    public var onChangeHandler: ((String) -> Void)?
  • Indicates if the value of the cell could be changed or not. For FUISimplePropertyFormCell this property is always false.

    Declaration

    Swift

    open var isEditable: Bool = false
  • The key name of the property.

    Declaration

    Swift

    open var keyName: String?
  • The UILabel holds the key name string.

    Declaration

    Swift

    @IBOutlet open weak var keyLabel: UILabel!
  • The UITextField holds the value string.

    Declaration

    Swift

    @IBOutlet open weak var valueTextField: UITextField!
  • If isTrackingLiveChanges == true, then onChangeHandler will be invoked for every letter entered. Otherwise, onChangeHandler will be invoked only after user taps Done key, or the field resigns first responder.

    Defaults to false.

    Declaration

    Swift

    open var isTrackingLiveChanges: Bool = false
  • The placeholder text for the value text field.

    Declaration

    Swift

    open var placeholderText: String?