IHPickFloorCell.swift 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //
  2. // IHPickFloorCell.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2020/3/18.
  6. // Copyright © 2020 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. class IHPickFloorCell: UITableViewCell {
  10. var currentIndexPath:IndexPath?
  11. var completion:((DropDownData)->Void)?
  12. var buildList:[DropDownData]?{didSet{
  13. self.floorView.removeSubviews()
  14. self.floorView.addSubview(self.buttonView)
  15. self.buttonView.frame = self.floorView.bounds
  16. self.buttonView.reloadData()
  17. }}
  18. lazy var buttonView: IHButtonView = {
  19. let buttonView = IHButtonView()
  20. buttonView.delegate = self
  21. return buttonView
  22. }()
  23. @IBOutlet weak var buildLabel: UILabel!
  24. @IBOutlet weak var floorView: UIView!
  25. override func awakeFromNib() {
  26. super.awakeFromNib()
  27. }
  28. override func setSelected(_ selected: Bool, animated: Bool) {
  29. super.setSelected(selected, animated: animated)
  30. }
  31. }
  32. extension IHPickFloorCell:IHButtonViewDelegate{
  33. func numberofItem(in buttonView: IHButtonView) -> Int {
  34. return self.buildList?.count ?? 0
  35. }
  36. func buttonView(_ buttonView: IHButtonView, titleFor item: Int) -> String {
  37. return (self.buildList![item].name)!
  38. }
  39. func buttonView(_ buttonView: IHButtonView, didSelected item: Int) {
  40. log.debug(self.buildList![item].name)
  41. let build = self.buildList![item]
  42. if build.name == "所有" {
  43. if self.buildList!.count > 1 {
  44. if let block = completion {
  45. block(self.buildList![1])
  46. }
  47. }
  48. }
  49. if let block = completion {
  50. block(self.buildList![item])
  51. }
  52. }
  53. }