FileTableViewCell.swift 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. //
  2. // FileTableViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 16/9/13.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import CocoaLumberjack
  10. protocol FileTableViewCellDelegate {
  11. func cellDidClicked(_ cell:FileTableViewCell,file:OOFile)
  12. }
  13. class FileTableViewCell: UITableViewCell {
  14. @IBOutlet weak var fileIconImageView: UIImageView!
  15. @IBOutlet weak var fileNameLabel: UILabel!
  16. @IBOutlet weak var btnActionImageView: CellTouchImageView!
  17. var delegate:FileTableViewCellDelegate?
  18. var file:OOFile? {
  19. didSet {
  20. self.fileNameLabel.text = file?.name
  21. switch (file?.fileType)! {
  22. case .file:
  23. self.fileIconImageView.image = UIImage(named: O2.fileExtension2Icon((file?.extend)))
  24. break
  25. case .folder:
  26. self.fileIconImageView.image = UIImage(named: "file_folder_icon")
  27. }
  28. self.btnActionImageView.addGestureRecognizer(UITapGestureRecognizer(target: self, action: #selector(btnActionClick(_:))))
  29. // let tap = UITapGestureRecognizer(target: self, action: #selector(btnActionClick(_:)))
  30. // tap.delegate = self
  31. // self.btnActionImageView.addGestureRecognizer(tap)
  32. }
  33. }
  34. @objc func btnActionClick(_ sender:AnyObject?){
  35. //let imageView = sender as? UIImageView
  36. DDLogDebug("btn action Clicked")
  37. DDLogDebug("cell frame = \(self.frame),cell center = \(self.center)")
  38. delegate?.cellDidClicked(self, file: self.file!)
  39. }
  40. // func calcFileIcon(_ ext:String) -> String{
  41. // switch ext {
  42. // case "doc","docx":
  43. // return "file_doc_icon"
  44. // case "xls","xlsx":
  45. // return "file_excel_icon"
  46. // case "ppt","pptx":
  47. // return "file_ppt_icon"
  48. // case "pdf":
  49. // return "file_pdf_icon"
  50. // case "rar","zip","war":
  51. // return "file_compressFile_icon"
  52. // case "txt":
  53. // return "file_txt_icon"
  54. // case "jpg","png","gif","jpeg":
  55. // return "file_image_icon"
  56. // default:
  57. // return "file_unknown_icon"
  58. // }
  59. // }
  60. override func awakeFromNib() {
  61. super.awakeFromNib()
  62. // Initialization code
  63. }
  64. override func setSelected(_ selected: Bool, animated: Bool) {
  65. super.setSelected(selected, animated: animated)
  66. // Configure the view for the selected state
  67. }
  68. // override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
  69. // DDLogDebug(event.debugDescription)
  70. // }
  71. //
  72. // override func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldReceiveTouch touch: UITouch) -> Bool {
  73. // let point = touch.locationInView(self.btnActionImageView)
  74. // DDLogDebug("point = \(point)")
  75. // return false
  76. // }
  77. }