FUIDurationPickerFormCell
@IBDesignable
public class FUIDurationPickerFormCell : FUIInlineValidationTableViewCell, FUIPropertyFormCell
A UITableViewCell
subclass, which allows a user to read or enter a value, using a duration picker.
The developer should set the following properties on the cell, in their implementation of UITableViewDataSource
cellForRow(at:)
function:
keyName
: The key name of the propertyvalue
: The value of the property, asTimeInterval
And an onChangeHandler
:
onChangeHandler
: a handler closure, which is invoked on changes to the value
Optionally, the developer may provide
minInterval
: The minute interval to be used in the picker.isEditable
: Indicates if the cell’s value may be modified. Defaults totrue
.
Color configuration:
Call setTintColor(_:for:) to configure tint color for disabled, normal, selected UIControlState
. Setting tintColor
is equivalent to call setTintColor(color, for: UIControlState.normal).
- disabled: Color to be used when control is disabled.
- normal: Color to be used when control is enabled.
- selected: Color to be used when control is selected.
The following is an example of usage in an application UITableViewController
:
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.register(FUIDurationPickerFormCell, forCellReuseIdentifier: FUIDurationPickerFormCell.reuseIdentifier)
// ...
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: FUIDurationPickerFormCell.reuseIdentifier, for: indexPath) as! FUIDurationPickerFormCell
cell.keyName = "Duration"
cell.value = myObject.eventDuration // in seconds
// MARK: implement an onChangeHandler
cell.onChangeHandler = { newValue in
myObject.eventDuration = newValue
}
return cell
}
## Theming Supported style classes
fdlFUIDurationPickerFormCell
fdlFUIDurationPickerFormCell_keyLabel
fdlFUIDurationPickerFormCell_valueTextField
fdlFUIDurationPickerFormCell_valueTextField_selected
-
The UILabel holds the key name string.
Declaration
Swift
@IBOutlet public private(set) weak var keyLabel: UILabel!
-
The UITextField holds the selected value strings.
Declaration
Swift
@IBOutlet public private(set) weak var valueTextField: UITextField!
-
The
UIDatePicker
for this cell. It’s datePickerMode property is set to countDownTimer. It will be displayed only when this cell is selected.Declaration
Swift
@IBOutlet public private(set) weak var durationPicker: UIDatePicker!
-
The default cell reuse identifier.
Declaration
Swift
open class var reuseIdentifier: String { get }
-
The value type is TimeInterval.
Declaration
Swift
public typealias ValueType = TimeInterval
-
The default value is 0.0 Limit is 23:59 (86,399 seconds).
Declaration
Swift
public var value: TimeInterval { get set }
-
Implementation of change handler. Is invoked on changes to the
value
property.Declaration
Swift
public var onChangeHandler: ((Double) -> Void)?
-
minuteInterval must be evenly divided into 60. Default is 5. minimum is 1, maximum is 30.
Declaration
Swift
public var minuteInterval: Int { get set }
-
Indicates if the value of the cell may be modified. The default is
true
.Declaration
Swift
public var isEditable: Bool { get set }
-
If
isTrackingLiveChanges
is true, thenonChangeHandler
, will be invoked whenever a duration is selected.Otherwise,
onChangeHandler
will be invoked only when the Duration Picker is closed.The default value is
true
.Declaration
Swift
public var isTrackingLiveChanges: Bool
-
The key name of the cell.
Declaration
Swift
@IBInspectable public var keyName: String? { get set }
-
Set this property to customize the format of duration text. If this property is not set, using the default text format. The default text format is
%d Hrs %d Min
where %d is the number of hours and minutes.Declaration
Swift
public var durationTextFormat: String! { get set }
-
Undocumented
Declaration
Swift
public override var tintColor: UIColor! { get set }