ImageSlidesShowTableViewCell.swift 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. //
  2. // ImageSlidesShowTableViewCell.swift
  3. // O2Platform
  4. //
  5. // Created by 刘振兴 on 2016/12/5.
  6. // Copyright © 2016年 zoneland. All rights reserved.
  7. //
  8. import UIKit
  9. import ImageSlideshow
  10. import Alamofire
  11. import AlamofireImage
  12. import AlamofireObjectMapper
  13. import ObjectMapper
  14. protocol ImageSlidesShowTableViewCellDelegate {
  15. func ImageSlidesShowClick(taskImageshowEntity:TaskImageshowEntity)
  16. }
  17. class ImageSlidesShowTableViewCell: UITableViewCell {
  18. @IBOutlet weak var imageSlideshow: ImageSlideshow!
  19. var delegate:ImageSlidesShowTableViewCellDelegate?
  20. var imageshowEntitys:[TaskImageshowEntity] = [] {
  21. didSet {
  22. self.imageURLS.removeAll(keepingCapacity: true)
  23. imageshowEntitys.forEach { (taskImageshowEntity) in
  24. let afurl = O2AlamofireSource(urlString: taskImageshowEntity.url!)
  25. self.imageURLS.append(afurl!)
  26. }
  27. // imageshowEntitys.forEachEnumerated { (index,taskImageshowEntity) in
  28. // let afurl = O2AlamofireSource(urlString: taskImageshowEntity.url!)
  29. // self.imageURLS.append(afurl!)
  30. // }
  31. imageSlideshow.setImageInputs(imageURLS)
  32. }
  33. }
  34. fileprivate var imageURLS:[O2AlamofireSource] = []
  35. override func awakeFromNib() {
  36. super.awakeFromNib()
  37. imageSlideshow.backgroundColor = UIColor.white
  38. imageSlideshow.slideshowInterval = 15.0
  39. imageSlideshow.preload = .all
  40. imageSlideshow.pageControlPosition = PageControlPosition.insideScrollView
  41. imageSlideshow.pageControl.currentPageIndicatorTintColor = UIColor.lightGray;
  42. imageSlideshow.pageControl.pageIndicatorTintColor = UIColor.black;
  43. imageSlideshow.contentScaleMode = UIView.ContentMode.scaleToFill
  44. imageSlideshow.addTapGesture(target: self, action: #selector(imageSlideshowClick(sender:)))
  45. }
  46. public func imageSlideshowClick(sender:ImageSlideshow?){
  47. //print(self.imageSlideshow.currentPage)
  48. if delegate != nil{
  49. let entity = self.imageshowEntitys[self.imageSlideshow.currentPage]
  50. self.delegate?.ImageSlidesShowClick(taskImageshowEntity: entity)
  51. }
  52. }
  53. override func setSelected(_ selected: Bool, animated: Bool) {
  54. super.setSelected(selected, animated: animated)
  55. // Configure the view for the selected state
  56. }
  57. }