UIScrollViewDelegate
@protocol UIScrollViewDelegate
几个概念的理解:
contentSize:可滑动区域的大小 (即这个区域内的内容是可以滑动的!scrollview的frame 表示所有可滑动的内容,都在这个frame中进行滑动)
例子:
scrView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 44, 320, 417)]; [scrView setContentSize:CGSizeMake(320,(220+heightOfTabFirst+CELL_CONTENT_MARGIN+heightOfTabSecond+CELL_CONTENT_MARGIN))];
contentOffset:滑动视图里面的内容的相对位置
contentInset:滑动视图在外面的相对位置
1、只要view有滚动(不管是拖、拉、放大、缩小等导致)都会执行此函数
-(void)scrollViewDidScroll:(UIScrollView *)scrollView;
2、将要开始拖拽,手指已经放在view上并准备拖动的那一刻
-(void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
3、将要结束拖拽,手指已拖动过view并准备离开手指的那一刻,注意:当属性pagingEnabled为YES时,此函数不被调用
-(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset;
4、已经结束拖拽,手指刚离开view的那一刻
-(void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate
5、view将要开始减速,view滑动之后有惯性
-(void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView;
6、view已经停止滚动
-(void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
7、view的缩放
-(void)scrollViewDidZoom:(UIScrollView *)scrollView
8、有动画时调用
-(void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;