FUITitleFormCell

open class FUITitleFormCell : FUIInlineValidationTableViewCell, FUIFormCell, UITextFieldDelegate

The reusable UI component implemented as an UITableViewCell to allow user to enter a value, using a UITextField.

FUITitleFormCell

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

  • value: The value of the property, as String

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.

Color settings:

Setting tintColor for valueTextField for a state using setTintColor(_:for:) api. Currently disabled and normal are supported.

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

Remark

The font-color attribute will be overridden by tint-color-disabled attribute when cell is switched to disabled state. DO NOT set textColor for valueTextField when cell is in disabled state!

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

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

   cell.value = myObject.title
   cell.isEditable = true

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

## Theming Supported style classes

 fdlFUITitleFormCell
 fdlFUITitleFormCell_valueTextField
  • The default cell reuse identifier.

    Declaration

    Swift

    open class var reuseIdentifier: String { get }
  • The value type for the FUITitleFormCell is String

    Declaration

    Swift

    public typealias ValueType = String
  • The value for FUITitleFormCell is the text of the Title.

    Declaration

    Swift

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

    Declaration

    Swift

    public var onChangeHandler: ((String) -> Void)?
  • Indicates if this title is editable or not. The default is true.

    Declaration

    Swift

    public var isEditable: Bool { get set }
  • isEnabled and isEditable are in sync.

    Declaration

    Swift

    override public var isEnabled: Bool { get set }
  • The UITextField to hold the title string.

    Declaration

    Swift

    @IBOutlet
    public private(set) weak var valueTextField: FUITextField! { get }
  • This is the maximum length of the title text, if maxTitleTextLength is greater than 0. If the text length reaches this limit, the user cannot enter more text. Note: If the user pastes a string and the length plus the current text length is greater than the limit, the insert is rejected. Partial strings are not accepted in the text field. The default value for maxTitleTextLength is 0, which means no limit.

    Declaration

    Swift

    public var maxTitleTextLength: Int
  • The type of the keyboard being used when the cell is in input mode.

    Declaration

    Swift

    public var keyboardType: UIKeyboardType { get set }
  • If isTrackingLiveChanges == true, then didChangeValue function of 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.

    Declaration

    Swift

    public var isTrackingLiveChanges: Bool { get set }
  • The placeholder text for the title text field.

    Declaration

    Swift

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