IGColorPicker
IGColorPicker copied to clipboard
Scroll to preselectedIndex doesn't work correctly
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.
What about viewWillLayoutSubviews or viewDidLayoutSubviews?
Thank you! It works :). But wouldn't it more obvious if will work even when changed on viewDidLoad?
No, on viewDidLoad, the view controller has not laid out its subviews yet.
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.