FUIDurationPickerFormCell
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
.
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
}
-
The value type is TimeInterval.
Declaration
Swift
public typealias ValueType = TimeInterval
-
The UILabel holds the key name string.
Declaration
Swift
@IBOutlet public weak var keyLabel: UILabel!
-
The UITextField holds the selected value strings.
Declaration
Swift
@IBOutlet public 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 weak var durationPicker: UIDatePicker!
-
The default cell reuse identifier.
Declaration
Swift
open static var reuseIdentifier: String
-
The default value is 0.0 Limit is 23:59 (86,399 seconds).
Declaration
Swift
public var value: TimeInterval
-
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 = 5
-
Indicates if the value of the cell may be modified. The default is
true
.Declaration
Swift
public var isEditable = true
-
The key name of the cell.
Declaration
Swift
public var keyName: String?
-
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!