OOFormTextItemView.swift 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. //
  2. // OOMeetingTextItemView.swift
  3. // o2app
  4. //
  5. // Created by 刘振兴 on 2018/1/25.
  6. // Copyright © 2018年 zone. All rights reserved.
  7. //
  8. import UIKit
  9. class OOFormTextItemView: OOFormBaseView,OOFormConfigEnable {
  10. @IBOutlet weak var titleLabel: UILabel!
  11. @IBOutlet weak var valueTextField: UITextField!
  12. @IBOutlet weak var showValueLabel: UILabel!
  13. override func awakeFromNib() {
  14. showValueLabel.isHidden = true
  15. }
  16. override init(frame: CGRect) {
  17. super.init(frame: frame)
  18. }
  19. required init?(coder aDecoder: NSCoder) {
  20. super.init(coder: aDecoder)
  21. }
  22. func configItem(_ model: OOFormBaseModel) {
  23. self.model = model
  24. titleLabel.text = self.model?.titleName
  25. if self.model?.itemStatus! == .read {
  26. self.valueTextField.isHidden = true
  27. self.showValueLabel.isHidden = false
  28. self.showValueLabel.text = self.model?.callbackValue as? String ?? ""
  29. }else{
  30. self.valueTextField.isHidden = false
  31. self.valueTextField.addTarget(self, action: #selector(textFieldDidChange(_:)), for: .editingChanged)
  32. self.valueTextField.text = self.model?.callbackValue as? String ?? ""
  33. self.showValueLabel.isHidden = true
  34. }
  35. }
  36. }
  37. // MARK:- 监听文本变化
  38. extension OOFormTextItemView {
  39. @objc func textFieldDidChange(_ textField:UITextField) {
  40. self.model?.callbackValue = textField.text
  41. }
  42. }