Table view does not bounce correctly when changing constraints

I am implementing a simple view consisting of a UIView with a table view below it.

I implement scrollViewDidScroll and change the upper limit of the UIView, which works fine:

        headerTopConstraint.constant = -scrollY - 65

(- 65 - original restriction)

The problem is that when the constraint constant is constantly changing, I don't get the scanned view of the table view when scrolling down when there is no content to scroll down.

Instead, it simply “tries” to bounce, but immediately returns to its original position. Example: http://jmp.sh/rTBfzCM

If I delete only one line of code, the rebound works fine: http://jmp.sh/AtVYwPy

In the table view, there is a limit to the top space 0 on the UIView.

+4
source share
1 answer

I think the reason is that this is because this line of code dynamically changes the constraint constant depending on the current scrollY value.

, scrollview y. , "bounce" , . , , "" /, , . , , scrollview .

? , .


1 , View tableView? - ( ):

//Check if user has scrolled through all content within tableview
//If not, update constraint constant
if scrollY < self.tableView.contentSize.height - tableView.frame.size.height {
    headerTopConstraint.constant = -scrollY - 65
}
+2

Source: https://habr.com/ru/post/1621369/


All Articles