1 year ago
#365701
whitekevin
UIScrollView setContentOffset back to top, stop at incorrect contentOffset
I have a button at the top of UITableView
, once I tap the button, will call setContentOffset(:animated:)
of this UITableView
to back to the contentOffset I want, which is -button.height
.
Most of time it works, while since my tableView support paging, when I scroll down the tableView, it will load more data after request finish. here is the issues happened, after I loading the second page,
I call this method again when I tap the button,setContentOffset(:animated:)
, it will stop in another offset location. I guess it might related to some bouncing stuff, anyone knows the answer, thanks~
Update
Figure out the root cause is my UITableView's cell's height is automatic height, estimatedRowHeight = automaticDimension
based on Apple's doc
When using height estimates,
the table view actively manages the contentOffset and contentSize properties inherited from its scroll view.
Do not attempt to read or modify those properties directly.
so I give up to call setContentOffset(:animated:)
directly, instead of I use scrollToRow
ios
swift
uitableview
uiscrollview
contentoffset
0 Answers
Your Answer