码迷,mamicode.com
首页 > 其他好文 > 详细

UIScrollViewDelegate协议方法

时间:2020-03-05 23:41:43      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:dia   change   ant   already   距离   dde   void   视图   distance   

#pragma mark 监听滚动停止

// called on start of dragging (may require some time and or distance to move)
// 开始拖动时调用(可能需要一些时间或距离才能移动)
// 开始拖动时(手指在屏幕上)
- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView {
    NSLog(@"111~~~~~~~~~~scrollViewWillBeginDragging:%ld", (long)scrollView.contentOffset.y);
}

// any offset changes
// 任何偏移更改
- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    NSLog(@"222~~~~~~~~~~scrollViewDidScroll:%ld", (long)scrollView.contentOffset.y);
}

// called on finger up if the user dragged. velocity is in points/millisecond. targetContentOffset may be changed to adjust where the scroll view comes to rest
// 如果用户拖动,则调用finger up。速度以点/毫秒为单位。可以更改targetContentOffset以调整滚动视图的静止位置
// 结束拖动时(手指离开屏幕)的速度(正-往上的速度,负-往下的速度)
- (void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset {
    NSLog(@"333~~~~~~~~~~scrollViewWillEndDragging:%ld, velocity:%lf", (long)scrollView.contentOffset.y, velocity.y);
}

// called on finger up if the user dragged. decelerate is true if it will continue moving afterwards
// 如果用户拖动,则调用finger up。如果减速后继续移动,则为真
// 拖动完之后,如果会滑行,则为真
- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    NSLog(@"444~~~~~~~~~~scrollViewDidEndDecelerating:%ld, decelerate:%d", (long)scrollView.contentOffset.y, decelerate);
}

// called on finger up as we are moving
// 当我们移动的时候手指向上
// 开始滑行
- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView {
    NSLog(@"555~~~~~~~~~~scrollViewWillBeginDecelerating:%ld", (long)scrollView.contentOffset.y);
}

// called when scroll view grinds to a halt
// 当scroll view磨合停止时调用
// 停止滑行
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
    NSLog(@"666~~~~~~~~~~scrollViewDidEndDecelerating:%ld", (long)scrollView.contentOffset.y);
}

// called when setContentOffset/scrollRectVisible:animated: finishes. not called if not animating
// 当setContentOffset/scrollRectVisible:animated:finishes完成时调用。如果不设置动画,则不调用
- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView {
 NSLog(@"777~~~~~~~~~~scrollViewDidEndScrollingAnimation:%ld", (long)scrollView.contentOffset.y);
}

// called when scrolling animation finished. may be called immediately if already at top
// 当滚动动画完成时调用。如果已经在顶部,可以立即调用
// 当点击状态栏tableView回到顶部时调用
- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView {
    NSLog(@"888~~~~~~~~~~scrollViewDidScrollToTop:%ld", (long)scrollView.contentOffset.y);
}

// Also see -[UIScrollView adjustedContentInsetDidChange]
// tableView刚出现时会调用
- (void)scrollViewDidChangeAdjustedContentInset:(UIScrollView *)scrollView {
    NSLog(@"999~~~~~~~~~~scrollViewDidChangeAdjustedContentInset:%ld", (long)scrollView.contentOffset.y);
}

// return a yes if you want to scroll to the top. if not defined, assumes YES
// 如果要滚动到顶部,请返回“是”。如果没有定义,则假设是
- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView {
    return YES;
}

 

UIScrollViewDelegate协议方法

标签:dia   change   ant   already   距离   dde   void   视图   distance   

原文地址:https://www.cnblogs.com/cchHers/p/12423838.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!