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.

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
}

  • The value type for the FUITitleFormCell is String

    Declaration

    Swift

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

    Declaration

    Swift

    open static var reuseIdentifier: String
  • The value for FUITitleFormCell is the text of the Title.

    Declaration

    Swift

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

    Declaration

    Swift

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

    Declaration

    Swift

    open var isEditable = true
  • The UITextField to hold the title string.

    Declaration

    Swift

    @IBOutlet open weak var valueTextField: FUITextField!
  • 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

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

    Declaration

    Swift

    open var keyboardType: UIKeyboardType = .default
  • 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

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

    Declaration

    Swift

    open var placeholderText: String?