-
Notifications
You must be signed in to change notification settings - Fork 60
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
TLIndexPathUpdates should optionally suppress scrolling when inserting rows #12
Comments
Thanks for the suggestion. I'm pretty slammed with work this month, so you might consider applying the workaround you linked to yourself if you're in a hurry. Maybe you could use the workaround instead of calling |
Sure. Would you be interested in a pull request that added this functionality? |
Sure. But I've been meaning to add an expanded API for
I'd think the minimize scroll option would for now simply kick over to the above technique anytime it can be determined that the table's visible state can be preserved as-is. |
OK, I can include that. In which cases should |
None for now I think. I mainly included it to be consistent with the API on
and with the |
I'm unable to get the UITableView to report any
and
But no matter what, Do you have any ideas? If we can't get that to work, here are a few alternatives:
A possible interface for alternative 2 could be:
|
Before answering your question, I spent a couple hours last night on a more generic approach that would work more generically with batch updates without requiring the use of Regarding your question, why are you wanting the table view to report |
Since the table view stores its content size, my plan was:
We could take a similar approach, getting the height for each item by calling The I hadn't seen |
Yeah, it's too bad about the Here are a few thoughts that might help:
Sorry I don't have more time to dig into this. |
That's OK, I'll work in it more. I think the tableview might cache the heights by itself, so I might be able to get the heights of the deleted rows by calling |
I noticed that this works for UITableView:
I am fixing the It only works with Should I create a demo project? |
@stefreak I've long since abandoned the project I was working on in 2014, so I would love to look at a sample project. |
@getaaron KeepScrollPositionDemo.zip Somehow the row animation doesn't work in the demo, but I'm pretty sure it did work in another project. I am not sure if this approach could/should be ported to I am also not sure if this only works because of the |
The row animation seems to work when the row is updated in my other project, so yeah it only works correctly without any animations. but it's still better than reloadData because the cells that did not change are preserved |
If the user is scrolled down 20 messages on a table, and a new message comes in, calling
[TLIndexPathUpdates -performBatchUpdatesOnTableView: withRowAnimation:]
will insert rows at the top, pushing the other cells down. It can be confusing for a user to have the table scroll all of a sudden, so an option should be provided to suppress this behavior during row insertion.This Stack Overflow answer describes one method for inserting rows at the top, and manually adjusting the table's
contentOffset
so the user never notices anything.The text was updated successfully, but these errors were encountered: