ZoneFileListCell.swift 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. //
  2. // ZoneFileListCell.swift
  3. // ZoneBarManager
  4. //
  5. // Created by 刘振兴 on 2017/3/15.
  6. // Copyright © 2017年 zone. All rights reserved.
  7. //
  8. import UIKit
  9. protocol ZoneFileListCellDelegate {
  10. func cellClick(_ model:ZonePickerModel)
  11. }
  12. class ZoneFileListCell: UITableViewCell {
  13. @IBOutlet weak var fileIconImageView: UIImageView!
  14. @IBOutlet weak var fileTitleLabel: UILabel!
  15. var pickerModel:ZonePickerModel! {
  16. didSet {
  17. self.fileTitleLabel.text = pickerModel.name
  18. let name = pickerModel.name
  19. let nameArray = name?.split(".")
  20. if nameArray != nil, let ext = nameArray?.last {
  21. if let img = UIImage(named: "file_\(ext)_icon") {
  22. self.fileIconImageView.image = img
  23. }else{
  24. self.fileIconImageView.image = #imageLiteral(resourceName: "file_unknown_icon")
  25. }
  26. }else{
  27. self.fileIconImageView.image = #imageLiteral(resourceName: "file_unknown_icon")
  28. }
  29. }
  30. }
  31. var delegate:ZoneFileListCellDelegate!
  32. override func awakeFromNib() {
  33. super.awakeFromNib()
  34. // Initialization code
  35. }
  36. override func setSelected(_ selected: Bool, animated: Bool) {
  37. super.setSelected(selected, animated: animated)
  38. // Configure the view for the selected state
  39. }
  40. @IBAction func fileCellClick(_ sender: UIButton) {
  41. print("fileCellClick")
  42. if let d = delegate {
  43. d.cellClick(self.pickerModel)
  44. }
  45. }
  46. }