Implement cellBecomeFirstResponder and cellResignFirstResponder for SliderTextFieldRow

pull/2/head
Michael Scoff 7 years ago
parent fb6663cd77
commit e20cf27836
  1. 14
      Trust/UI/Form/SliderTextFieldRow.swift

@ -101,7 +101,7 @@ open class SliderTextFieldCell: Cell<Float>, CellType, UITextFieldDelegate {
guard !awakeFromNibCalled else { return }
textField.heightAnchor.constraint(equalToConstant: 30).isActive = true
textField.widthAnchor.constraint(equalToConstant: 160).isActive = true
textField.widthAnchor.constraint(equalToConstant: 140).isActive = true
let views: [String: Any] = ["titleLabel": titleLabel, "textField": textField, "slider": slider]
let metrics = ["vPadding": 12.0, "spacing": 12.0]
@ -157,6 +157,18 @@ open class SliderTextFieldCell: Cell<Float>, CellType, UITextFieldDelegate {
@objc public func textFieldShouldReturn(_ textField: UITextField) -> Bool {
return true
}
open override func cellCanBecomeFirstResponder() -> Bool {
return !row.isDisabled && textField.canBecomeFirstResponder == true
}
open override func cellBecomeFirstResponder(withDirection: Direction) -> Bool {
return textField.becomeFirstResponder()
}
open override func cellResignFirstResponder() -> Bool {
return textField.resignFirstResponder()
}
}
/// A row that displays a UISlider. If there is a title set then the title and value will appear above the UISlider.

Loading…
Cancel
Save