FUINoteFormCell
@IBDesignable
open class FUINoteFormCell : FUIInlineValidationTableViewCell, FUIFormCell, UITextViewDelegate
The reusable UI component implemented as an UITableViewCell
to allow user enter notes.
Optionally, the developer may provide:
value
: The default text in the note.placeholderText
: The placeholder string to be put on the text area before user typed anything.isAutoFitting
: If this is true, the scroll will be disabled and the height of the cell will grow and shrink as needed. There is a minimum height that the cell will maintain.isEditable
: Indicates if the note text could be modified or not. The default is true.onChangeHandler
: a handler closure, which is invoked on changes to the value
Color setting:
Setting text color of valueTextView
for a state using setTintColor(_:for:) api. Currently .disabled
and .normal
are supported.
cell.setTintColor(UIColor.red, for: .normal)
Remark
Thefont-color
attribute will be overridden by tint-color-disabled
attribute when cell is switched to disabled
state. DO NOT set textColor
for valueTextView
when cell is in disabled
state!
The following is an example of usage in an application UITableViewController
:
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(FUINoteFormCell.self, forCellReuseIdentifier: FUINoteFormCell.reuseIdentifier)
// ...
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: FUINoteFormCell.reuseIdentifier, for: indexPath) as! FUINoteFormCell
// If a value already exists, set it to the `value` property
cell.value = myObject.note
// Specify an optional placeholder text
cell.placeholderText = "Description"
// MARK: implement onChangeHandler
cell.onChangeHandler = { newValue in
myObject.note = newValue
}
return cell
}
## Theming Supported style classes
fdlFUINoteFormCell
fdlFUINoteFormCell_valueTextView
-
The default cell reuse identifier.
Declaration
Swift
open class var reuseIdentifier: String { get }
-
Undocumented
Declaration
Swift
public typealias ValueType = String
-
The note string.
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 the note text could be modified or not. The default is true.
Declaration
Swift
public var isEditable: Bool { get set }
-
The placeholder string to be put on the text area before user typed anything.
Declaration
Swift
@IBInspectable public var placeholderText: String? { get set }
-
The UI component holds the note text.
Declaration
Swift
@IBOutlet public private(set) weak var valueTextView: FUITextViewExt!
-
If
isTrackingLiveChanges
is true, thenonChangeHandler
will be invoked for every letter entered.Otherwise,
onChangeHandler
will be invoked only after user tapsDone
key, or the field resigns first responder.Defaults to
false
.Declaration
Swift
public var isTrackingLiveChanges: Bool
-
If this is true, this
FUINoteFormCell
will grow in height and the cell will not be scrollable. Otherwise, the cell height will be fixed.Declaration
Swift
public var isAutoFitting: Bool { get set }
-
This is the maximum length of the note text, if maxNoteTextLength 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 maxNoteTextLength is 0, which means no limit.
Declaration
Swift
public var maxNoteTextLength: Int
-
The type of the keyboard being used when the cell is in input mode.
Declaration
Swift
public var keyboardType: UIKeyboardType { get set }
-
Declaration
Swift
open override var nibLoadingClass: AnyClass { get }