NewMainAppTableViewCell.swift 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. //
  2. // NewMainAppTableViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2017/3/12.
  6. // Copyright © 2017年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import EmptyDataSet_Swift
  10. protocol NewMainAppTableViewCellDelegate {
  11. func NewMainAppTableViewCellWithApp(_ app:O2App)
  12. func emptyTapClick()
  13. }
  14. class NewMainAppTableViewCell: UITableViewCell,Configurable {
  15. @IBOutlet weak var appCollectionView: UICollectionView!
  16. private var collectionViewDelegate = NewMainCollectionView()
  17. var delegate:NewMainAppTableViewCellDelegate!
  18. var apps:[O2App] = [] {
  19. didSet {
  20. collectionViewDelegate.apps.removeAll()
  21. collectionViewDelegate.apps.append(contentsOf: apps)
  22. self.appCollectionView.reloadData()
  23. }
  24. }
  25. override func awakeFromNib() {
  26. super.awakeFromNib()
  27. //实现点击反向代理
  28. self.collectionViewDelegate.delegate = self
  29. //空数据集显示
  30. self.appCollectionView.emptyDataSetSource = collectionViewDelegate
  31. self.appCollectionView.emptyDataSetDelegate = collectionViewDelegate
  32. // //实现数据展现代理
  33. self.appCollectionView.dataSource = collectionViewDelegate
  34. self.appCollectionView.delegate = collectionViewDelegate
  35. //self.appCollectionView.reloadData()
  36. }
  37. func config(withItem item: Any?) {
  38. guard let myApps = item as? [O2App] else {
  39. return
  40. }
  41. apps.removeAll()
  42. apps.append(contentsOf: myApps)
  43. //self.appCollectionView.reloadData()
  44. }
  45. override func setSelected(_ selected: Bool, animated: Bool) {
  46. super.setSelected(selected, animated: animated)
  47. // Configure the view for the selected state
  48. }
  49. }
  50. extension NewMainAppTableViewCell:NewMainCollectionViewDelegate{
  51. func NewMainCollectionViewItemClickWithApp(_ app: O2App) {
  52. if let d = delegate {
  53. d.NewMainAppTableViewCellWithApp(app)
  54. }
  55. }
  56. func emptyTapClick() {
  57. if let d = delegate {
  58. d.emptyTapClick()
  59. }
  60. }
  61. }