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
CocoaList initialContentAlignment issue #32
Comments
I have done more tests in a simpler project and was not able to reproduce the multiple calls to the observeValue. |
I was able to reproduce the issue in a demo project by adding a vertical padding:
You can use this code to reproduce the bug. |
@MatteCarra I'm currently struggling to fix content offset correction myself - |
Thanks for the confirmation. |
@MatteCarra if you need this functionality ASAP - I'd recommend you try raising a workaround/patch PR (you seem to have understood the issue exactly). I'm available if you need any assistance in understanding the code - which I understand is under-documented currently. |
I'm not in a rush, by I'm actively trying to find a solution to the problem. I'm looking forward on collaborating to this great project. |
I was able to perform some working tests with CocoaList, but I have some questions for the desired implementation. What is initialContentAlignment designed to do? I think that a common use case of initialContentAlignment could be for a logs/chat view: messages start filling from top until all the view is filled and then the list is automatically scrolled to the last element whenever a new item is added. I would also need to know why you imposed the condition Please let me know. |
@MatteCarra the purpose of The reason I'd imposed that condition is because |
I have noticed an issue with current CocoaList initialContentAlignment implementation.
The issue seems to be in UIHostingTableViewController.correctContentOffset function.
This function is called whenever content size is updated by the observe value function in the event a view is added to the data source.
The issue here is the oldContentSize value: observeValue seems to be called multiple times with values like:
You seem to have noticed this in correctContentOffset:
You then calculate the offset like this:
but the delta is way higher than it should be (722-452 instead of 722-642) resulting in a wrong content offset.
If you remove the said guard the delta would be correct, but the offset will be set even when
tableView.frame.size.height < newContentSize.height
causing the view to be scrolled to bottom even when the content is not filling the whole frame.You can't even guard on that condition because the condition could match the second call from observeValue and not the first one.
I'm new to UIKit and I have no idea why it's behaving like that.
I'm looking forward to hear your opinion on that.
Thanks.
The text was updated successfully, but these errors were encountered: