evgenyneu / Auk

An image slideshow for iOS written in Swift.
MIT License
278 stars 44 forks source link

How to enable page indicator? #28

Closed danielpassos closed 8 years ago

danielpassos commented 8 years ago

What I need to do to enable the page indicator? I cloud not find any reference about it in your demo app.

    override func viewDidLoad() {
        scrollView.auk.settings.showsHorizontalScrollIndicator = true
        scrollView.auk.settings.pageControl.visible = true
        scrollView.auk.settings.contentMode = UIViewContentMode.ScaleAspectFill

        let image1 = UIImage(named: "banner_top.jpg")
        self.scrollView.auk.show(image: image1!, accessibilityLabel: "Top")

        let image2 = UIImage(named: "banner_conteudo.jpg")
        self.scrollView.auk.show(image: image2!, accessibilityLabel: "Conteúdo")

        let image3 = UIImage(named: "banner_eventos.jpg")
        self.scrollView.auk.show(image: image3!, accessibilityLabel: "Eventos")

        scrollView.auk.startAutoScroll(delaySeconds: 3)
    }

2016-05-29 18-28-38

evgenyneu commented 8 years ago

Hi @danielpassos, this is weird indeed. The page indicator should be visible by default. This issue could appear if the scroll view is not added to the main view in viewDidLoad where you add the images. Here is why:

One person had a similar issue because the scroll view was not installed in the default size class, therefore it was not in the main view during the viewDidLoad call.

This made the page indicator disappear:

size_classes

I hope that helps. Let me know how it goes.

danielpassos commented 8 years ago

@evgenyneu

Thanks for the very awesome reply. The only thing come in my mind now, is this view controller is embedded in a Container View.

Anyway, I will try to reproduce the same scenario in a clean/new app and play around tomorrow morning. I can publish it in my Github account and let you know here.

Thanks for the reply again!

evgenyneu commented 8 years ago

The container view may be the cause. To do a quick check I would print the value of scrollView.superview in the function where you show the images. If it's nil then the page control will not be created. In this case, you may want to show the images after the scroll view is added to the view, in viewWillAppear, for example.

danielpassos commented 8 years ago

Yeap, it is the problem, but seems I have the same using viewWillAppear

swift override func viewDidLoad() { print("scrollView.superview = (scrollView.superview)") }

scrollView.superview = nil


``` swift
override func viewWillAppear(animated: Bool) {
    print("scrollView.superview = \(scrollView.superview)")
}
scrollView.superview = nil
danielpassos commented 8 years ago

I did the same scenario I have in the clean/new app and it works like a charm with the same code, so it's seem be a specific problem in my project. I'll investigate. Thanks for your help anyway

auk-playground