FUISegmentedControlFormCell

open class FUISegmentedControlFormCell: FUIInlineValidationTableViewCell, FUIPropertyFormCell

A UITableViewCell subclass, which allows a user to view or select from a list of strings, using a Fiori-styled segmented control.

FUISegmentedControlFormCell

The value property of the cell is equal to the selectedSegmentIndex in the segmented control.

Code usage:

// Optionally, create an array of value option to localized string mappings
let buttonTitles: [[String: String]] = [[LO: Low], [MED: Medium], [HI: High]]

// Register FUISegmentedControlFormCell in viewDidLoad() method in the controller. override func viewDidLoad() { super.viewDidLoad() self.tableView.register(FUISegmentedControlFormCell.self, forCellReuseIdentifier: FUISegmentedControlFormCell.reuseIdentifier) }

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let cell = tableView.dequeueReusableCell(withIdentifier: FUISegmentedControlFormCell.reuseIdentifier, for: indexPath) as! FUISegmentedControlFormCell

cell.valueOptions = buttonTitles.flatMap { $0.map { $0.value } } cell.keyName = Priority cell.value = myObject.priority // String value in the valid options set: [LO, MED, HI]

// MARK: implement onChangeHandler cell.onChangeHandler = { newValue in myObject.priority = buttonTitles[newValue].first!.key // lookup valid String value, from the buttonTitles array }

return cell }

  • The type of the value

    Declaration

    Swift

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

    Declaration

    Swift

    open static var reuseIdentifier: String
  • The key name of the cell

    Declaration

    Swift

    open var keyName: String? = ""
  • The value of the cell

    Declaration

    Swift

    open var value: Int
  • The width of segment in the control. Default is 73. Setting this property has no effect if apportionsSegmentWidthsByContent is true.

    Declaration

    Swift

    open var segmentWidth: CGFloat
  • The height of segment in the control. Default is 32.

    Declaration

    Swift

    open var segmentHeight: CGFloat
  • Implementation of change handler. Is invoked on changes to the value property.

    Declaration

    Swift

    open var onChangeHandler: ((Int) -> Void)?
  • The array of the valid options.

    Declaration

    Swift

    open var valueOptions: [String] = [String]()
  • Indicates whether the user can change the selection or not. It is set to true by default.

    Declaration

    Swift

    open var isEditable = true
  • Indicates whether the control attempts to adjust segment widths based on their content widths. Default is false.

    Declaration

    Swift

    open var apportionsSegmentWidthsByContent: Bool
  • The key name label in the cell

    Declaration

    Swift

    @IBOutlet open weak var keyLabel: UILabel!