IGColorPicker icon indicating copy to clipboard operation
IGColorPicker copied to clipboard

Scroll to preselectedIndex doesn't work correctly

Open AmirL opened this issue 4 years ago • 4 comments

I tried to scroll this Picker to a default value, and unfortunately, it works only from viewDidAppear.

    override func viewDidAppear(_ animated: Bool) {
            colorPicker.preselectedIndex = Int(task.colorIndex)
    }

If I try to use from viewDidLoad or from viewWillAppear, it doesn't work at all. However viewDidAppear it is not very suitable for it, because it shows colors and scrolls only after. It looks like a bug.

AmirL avatar Sep 06 '20 08:09 AmirL

What about viewWillLayoutSubviews or viewDidLayoutSubviews?

iDevelopper avatar Sep 06 '20 12:09 iDevelopper

Thank you! It works :). But wouldn't it more obvious if will work even when changed on viewDidLoad?

AmirL avatar Sep 06 '20 14:09 AmirL

No, on viewDidLoad, the view controller has not laid out its subviews yet.

iDevelopper avatar Sep 06 '20 16:09 iDevelopper

viewDidLoad it's a good place to initialize variables. The thing is that the ColorPicker initializers ignore preselectedIndex but it definitely can be handled, right? I mean does it really matter when we change preselectedIndex? In a logical sense. It doesn't ignore other variables though.

AmirL avatar Sep 06 '20 16:09 AmirL