zvonicek / ImageSlideshow

Swift image slideshow with circular scrolling, timer and full screen viewer
MIT License
1.78k stars 478 forks source link

Error in UITableViewCell #268

Closed mohammadkalim closed 6 years ago

mohammadkalim commented 6 years ago

Hi,

I got an error in my TableView Content View there is another view which i want to add this slideshow in TableView but got the error

error: Illegal Configuration: The slideshow outlet from the HomeViewController to the ImageSlideshow is invalid. Outlets cannot be connected to repeating content.

I must have add the SlideShow inside the TableViewCell kindly let me know how to do that thanks.

mohammadkalim commented 6 years ago

Solved:

I just create the Individual Cell because i just forget my Table is Dynamic 👍

FOR HELPING PURPOSE I PASTE THE CODE BELOW

Thanks in advance for such a great POD ...

thumbs up 🥇

import UIKit
import ImageSlideshow

class SlideShowCell: UITableViewCell {

    @IBOutlet weak var SlideShow: ImageSlideshow?

    let localSource = [ImageSource(imageString: "banner1")!, ImageSource(imageString: "banner2")!]

    override func awakeFromNib() {
        super.awakeFromNib()

        SlideShow?.slideshowInterval = 5.0
        SlideShow?.pageIndicatorPosition = .init(horizontal: .center, vertical: .under)
        SlideShow?.contentScaleMode = UIViewContentMode.scaleAspectFill

        let pageControl = UIPageControl()
        pageControl.currentPageIndicatorTintColor = UIColor.lightGray
        pageControl.pageIndicatorTintColor = UIColor.black
        SlideShow?.pageIndicator = pageControl

        // optional way to show activity indicator during image load (skipping the line will show no activity indicator)
        SlideShow?.activityIndicator = DefaultActivityIndicator()
        SlideShow?.currentPageChanged = { page in
            print("current page:", page)
        }

        // can be used with other sample sources as `afNetworkingSource`, `alamofireSource` or `sdWebImageSource` or `kingfisherSource`
        SlideShow?.setImageInputs(localSource)

        let recognizer = UITapGestureRecognizer(target: self, action: #selector(SlideShowCell.didTap))
        SlideShow?.addGestureRecognizer(recognizer)

        // Initialization code
    }

    @objc func didTap() {
        let fullScreenController = SlideShow?.presentFullScreenController(from: (self.window?.rootViewController)!)
        // set the activity indicator for full screen controller (skipping the line will show no activity indicator)
        fullScreenController?.slideshow.activityIndicator = DefaultActivityIndicator(style: .white, color: nil)
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }

}