IHDevicePermisssionVCtr.swift 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. //
  2. // IHDevicePermisssionVCtr.swift
  3. // Inhealth
  4. //
  5. // Created by weclouds on 2019/12/23.
  6. // Copyright © 2019 weclouds. All rights reserved.
  7. //
  8. import UIKit
  9. import JXSegmentedView
  10. class IHDevicePermisssionVCtr: UIViewController ,UITableViewDelegate,UITableViewDataSource{
  11. let manager = IHPermissionManager()
  12. var devices : [String]?
  13. lazy var tableView : UITableView = {
  14. let tableView = UITableView(frame: CGRect(x: 0, y: 0, width: KSCREENWIDTH, height: KSCREENHEIGHT - KNavBarHeight - 50 ), style: .plain)
  15. // tableView.separatorStyle = .none
  16. tableView.backgroundColor = .white
  17. tableView.delegate = self
  18. tableView.dataSource = self
  19. return tableView
  20. }()
  21. override func viewDidLoad() {
  22. super.viewDidLoad()
  23. view.addSubview(tableView)
  24. IHPermissionService.share.getUserPermissInfo({ (rootNode, devices) in
  25. self.devices = devices
  26. self.tableView.reloadData()
  27. }) {
  28. }
  29. }
  30. func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
  31. return self.devices?.count ?? 0
  32. }
  33. func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
  34. return 50
  35. }
  36. func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
  37. var cell = tableView.dequeueReusableCell(withIdentifier: "cell")
  38. if cell == nil {
  39. cell = UITableViewCell(style: .default, reuseIdentifier: "cell")
  40. }
  41. cell?.textLabel?.text = devices![indexPath.row]
  42. cell?.textLabel?.font = UIFont(name: PingFangSC_Medium, size: 12)
  43. cell?.textLabel?.textColor = UIColor(hexString: "#333333")
  44. cell?.selectionStyle = .none
  45. return cell!
  46. }
  47. }
  48. extension IHDevicePermisssionVCtr:JXSegmentedListContainerViewListDelegate{
  49. func listView() -> UIView {
  50. return view
  51. }
  52. }