UIScrollView, reaching the bottom of the scroll view

后端 未结 7 1602
暗喜
暗喜 2020-12-07 16:05

I know the Apple documentation has the following delegate method:

- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;      // called when scroll         


        
7条回答
  •  萌比男神i
    2020-12-07 16:45

    I Think @bensnider answer is correct, But not exart. Because of these two reasons

    1. - (void)scrollViewDidScroll:(UIScrollView *)scrollView{}
    

    This method will call continuously if we check for if (bottomEdge >= scrollView.contentSize.height)

    2 . In this if we go for == check also this condition will valid for two times.

    • (i) when we will scroll up when the end of the scroll view touches the bottom edge
    • (ii) When the scrollview bounces back to retain it's own position

    I feel this is more accurate.

    Very few cases this codition is valid for two times also. But User will not come across this.

    - (void)scrollViewDidScroll:(UIScrollView *)scrollView
     {
        if (scrollView.contentOffset.y == roundf(scrollView.contentSize.height-scrollView.frame.size.height)) {
        NSLog(@"we are at the enffffdd");
    
       //Call your function here...
    
        }
    }
    

提交回复
热议问题