Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scroll to preselectedIndex doesn't work correctly #35

Open
AmirL opened this issue Sep 6, 2020 · 4 comments
Open

Scroll to preselectedIndex doesn't work correctly #35

AmirL opened this issue Sep 6, 2020 · 4 comments

Comments

@AmirL
Copy link

AmirL commented Sep 6, 2020

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.

@iDevelopper
Copy link

What about viewWillLayoutSubviews or viewDidLayoutSubviews?

@AmirL
Copy link
Author

AmirL commented Sep 6, 2020

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

@iDevelopper
Copy link

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

@AmirL
Copy link
Author

AmirL commented Sep 6, 2020

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants