-
Notifications
You must be signed in to change notification settings - Fork 92
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
[BUG] The default selected row is not the middle one. #8
Comments
@vanuccif Hello Thank you for caring about it. I'm so happy that you found it useful. Sorry about the delay, but I think you can set the Hope it solve this issue. All the best |
@vanuccif Hello! Just to add: It is a bug. I will fix it, thanks for reporting. Until a version with this fix is not released you can use the |
I faced the same issue and using currentSelectedRow did solve the issue temporarily, the problem with currentSelectedRow is it does not work in some cases where you have have say 100 rows, In my case it was from year 1900 to 2017 for year picker. If I give the value as 50 so that It centers at 1950, the highlight goes in the bottom element, bit if I give the currentSelectedRow as 2, it centers in the middle with 1902 selected. Thus disallowing me to center the element at 1950 make it center and highlight it. It would be nice to have this fix. One more suggestion is to add currentSelectedRow in the documentation, I could only find it after going through issues. |
Hi @azhararmar, I'm getting back to this project, organizing the things and fixing any bug that I wind up finding. I simulated the exact same scenario you provided on your comment and it worked properly setting the However, I fixed an issue some time ago that was causing the items to be selected at the bottom of the picker, maybe it was this other issue that was affecting you. Please, if you still suffer with this issue, make sure to update the |
@vanuccif Thinking again on this issue, actually the middle index for this case is subjective. If you want to round down, then the middle index is 2, but if you want to round up the middle index is 3. It is a matter of opinion. If we use EDITED: Sorry for the confusion, just to clarify: |
Hi,
thank you so much for this, it's really helpful!
I noticed that the default selected row is not the middle one.
I think the problem is in this code:
Int(ceil(Float(numberOfRowsByDataSource) / 2.0))
Since the row is an index, you have to subtract 1 to numberOfRowsByDataSource, to get the middle one.
For example if we have 5 items, ceil(2.5) is 3, but the middle item index is actually 2.
It would be great to have a public function (or delegate function) that lets you set the first selected item.
Thanks
The text was updated successfully, but these errors were encountered: