I have a doubt: is there any way to intercept a tableView
scrolling to add it an action? For example my prototype cell
background is red, touching up inside a cell its background color begin blue and scrolling the tableView
background color return red.
Is it possible to do this?!
Thanks in advance.
Since a scrollView has a panGesture we can check the velocity of that gesture. If the tableView was programmatically scrolled the velocity in both x and y directions is 0.0. By checking this velocity we can determine if the user scrolled the tableView because the panGesture has a velocity. Save this answer.
If the number or rows from the datasource is more than what can fit onscreen, the table will scroll. If you want to programmatically scroll the table, you can use the offset property on UIScrollView or one of the methods on UITableView to do that. D.C. Save this answer.
You need to set the UITableView scroll to false , tableview. scrollEnabled = false; tableview.
A view that presents data using rows in a single column.
UITableView
inherits from UIScrollView
and UITableViewDelegate
extends UIScrollViewDelegate
.
Particularly you may be interested in scrollViewDidScroll
method. So, in your UITableViewDelegate
implementation, add the following method:
func scrollViewDidScroll(_ scrollView: UIScrollView) {
NSLog("Table view scroll detected at offset: %f", scrollView.contentOffset.y)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With