How to show FullScreenSlideshowViewController on V

2019-06-08 21:17发布

问题:

I am new to iOS development, I have created android app where app gets sets of images (sometimes over 100 images) from urls and loads into imageView with zoomEnabled Inside ViewPager.

Now I want to create same app for iOS, I have found this lib ImageSliderShow. Problem with this is it shows fullscreen ONLY when user did tap on selected image. I have been struggling to presentFullScreenController on viewDidLoad with no lock.

I only want image to be shown in fullScreen, example:

Select Category A From CategoryVC -> Loads ImageSlideVC, gets set of images from server, show in FullScreenView.

How can i achieve this? Adding this:

slideshow.presentFullScreenController(from: self)

on viewDidLoad didn't work:

@IBOutlet var slideshow: ImageSlideshow!

let kingfisherSource = [KingfisherSource(urlString: "https://images.unsplash.com/photo-1447746249824-4be4e1b76d66?w=1080")!,
         KingfisherSource(urlString: "https://images.unsplash.com/photo-1447746249824-4be4e1b76d66?w=1080")!,
         KingfisherSource(urlString: "https://images.unsplash.com/photo-1463595373836-6e0b0a8ee322?w=1080")!]

override func viewDidLoad() {
    super.viewDidLoad()

    slideshow.setImageInputs(kingfisherSource)
    slideshow.presentFullScreenController(from: self)

}

I dont get any error, output is same as before (shows slideshow in smallview with no zoom)

Please help

EDIT

by doing in viewDidAppear, after split second view is loaded its loads into fullscreen. First its smallview then shows in fullscreen. I think i have to do something inside setImageInputs

this is what its looks like :

 open func setImageInputs(_ inputs: [InputSource]) {
    self.images = inputs
    self.pageControl.numberOfPages = inputs.count

    // in circular mode we add dummy first and last image to enable smooth scrolling
    if circular && images.count > 1 {
        var scImages = [InputSource]()

        if let last = images.last {
            scImages.append(last)
        }
        scImages += images
        if let first = images.first {
            scImages.append(first)
        }

        self.scrollViewImages = scImages
    } else {
        self.scrollViewImages = images
    }



    reloadScrollView()
    layoutScrollView()
    layoutPageControl()
    setTimerIfNeeded()
}

回答1:

try to do it in viewDidAppear

@IBOutlet var slideshow: ImageSlideshow!

 override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    slideshow.setImageInputs(kingfisherSource)
    slideshow.presentFullScreenController(from: self)

}

Presenting viewController in ViewDidLoad is a bad practice.