FUIKeyValueFormCell
@IBDesignable
open class FUIKeyValueFormCell : FUINoteFormCell, FUIPropertyFormCell
A customized UITableViewCell
, which contains a UILabel
and a UITextView
. It takes text as input.
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.placeholderText
: The placeholder of the property.value
: The value of the property, asString
.
And an onChangeHandler
:
onChangeHandler
: a handler closure, which is invoked on changes to the value.
Optionally, the developer may set
isAutoFitting
: Indicate if the cell height will adjust based on its content text. Default value is false.isTrackingLiveChanges
: Indicate howonChangeHandler
is invoked. If true,onChangeHandler
will be invoked every time a letter is entered or deleted; if false,onChangeHandler
will only be invoked when cell resigns first reponder.- ‘isEditable’: If the cell is editable or not. Default value is true. Date detector works only if this property is set to false.
Color setting:
Setting text color of filter buttons for a state using setTintColor(_:for:) api. Currently .disabled
and .normal
are supported.
cell.setTintColor(UIColor.red, for: .normal)
The following is an example of usage in an application UITableViewController
:
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(FUIKeyValueFormCell, forCellReuseIdentifier: FUIKeyValueFormCell.reuseIdentifier)
// ...
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: FUIKeyValueFormCell.reuseIdentifier, for: indexPath) as! FUIKeyValueFormCell
cell.keyName = "Note"
cell.placeholderText = "Description"
cell.value = myObject.descriptionText1
cell.isAutoFitting = true
cell.isTrackingLiveChanges = true
cell.isEditable = false
cell.onChangeHandler = { newValue in
self.myObject.descriptionText1 = newValue
}
return cell
}
Theming
Supported style classes
fdlFUIKeyValueFormCell
fdlFUIKeyValueFormCell_keyLabel
fdlFUIKeyValueFormCell_valueTextView