ios - UITableView Animate Height without ReloadData, Updates, or Edits -


i have tableview buttons can increase , decrease contentview's height of individual cells. individual cells have lot of configurations aren't persisted.(the end solution includes persisting data, there other issues follow) want able click button in cell, have cell expand pushing other cells down, , have cells keep configured data.

if use reloaddata, have persist everything, , lot of unnecessary reprocessing when editing 1 cell. lastly, there isn't free animation expand or shrink.

this leads table view updates , cell reloads come animations , less overhead. can call uitableview.beginupdates , uitableview.endupdates. or more ideally, call reloadrowsatindexpaths visible cells after editing cell. in case, animate height change while keep current cells data current. doesn't work.

finally, here problem. uitableview.beginupdates, uitableview.endupdates, , reloadrowsatindexpaths cause table view scroll. means if cell trying change height of has indexpath high enough, dequeued , reused. configuration data thrown out, , have cells aren't moving on screen being recycled. (i found out setting random background color on cell during prepareforreuse.)

now saying, duh simple disable implicit animations, , force reset tableview's contentoffset of underlying scrollview so:

uiview.setanimationsenabled(false) let contentoffset = tableview.contentoffset tableview.beginupdates() tableview.endupdates() tableview.setcontentoffset(contentoffset, animated: false) uiview.setanimationsenabled(true) 

well under hood, content offset change processed, , cells still recycled. there anyway around recycling?


Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -