//scrollView滚动时,就调用该方法。任何offset值改变都调用该方法。即滚动过程中,调用多次 - (void)scrollViewDidScroll:(UIScrollView *)scrollView { NSLog(@"scrollViewDidScroll"); CGPoint point=scrollView.contentOffset; NSLog(@"%f,%f",point.x,point.y); // 从中可以读取contentOffset属性以确定其滚动到的位置。 // 注意:当ContentSize属性小于Frame时,将不会出发滚动}
//when ScrollView is scaled, the method is called. Call back multiple times during scaling-(void) Scrollviewdidzoom: (uiscrollview *) ScrollView {nslog (@ "Scrollviewdidscroll"); float Value=scrollview.zoomscale; nslog (@ "%f", value);}
//when you start scrolling through the view, the method is executed. An effective slide (start sliding, slide a short distance, as long as the finger does not release, only one slide), only one time. -(void) scrollviewwillbegindragging:(Uiscrollview *) scrollview { nslog (@ "scrollviewwillbegindragging");}
//slide ScrollView, and the finger is left to execute. A valid slide, executed only once. //when the Pagingenabled property is yes, not called, the method-(void) Scrollviewwillenddragging: (uiscrollview *) ScrollView withvelocity: (cgpoint" Velocity targetcontentoffset: (inout cgpoint *) targetcontentoffset{NSLog ( @ "scrollviewwillenddragging");
//slide view, when the finger leaves the screen that moment, call the method. A valid slide, executed only once. //decelerate, referring to whether the view will continue to scroll forward (some distance) after our fingers leave that moment, tested, decelerate=yes-(void) scrollviewdidenddragging: (uiscrollview *) ScrollView Willdecelerate: (bool) decelerate{NSLog ( @ "scrollviewdidenddragging"); if (decelerate) {nslog (@ " Decelerate "); }else{nslog (@ "no Decelerate");} cgpoint point=scrollview.contentoffset; nslog (@ "%f,%f", Point.x,point.y);}
//the method is called when the slide slows down. -(void) scrollviewwillbegindecelerating:(Uiscrollview *) scrollview{nslog (@//the method after the Scrollviewdidenddragging method. }
//scroll view deceleration is complete and the method is called when scrolling stops. A valid slide, executed only once. -(void) scrollviewdidenddecelerating: (UIScrollView *) scrollview{nslog (@ "scrollviewdidenddecelerating"); [_scrollview setcontentoffset:cgpointmake (0, 500) animated:yes];}
//when the scrolling view animation is complete, call the method, and if there is no animation, then the method will not be called- ( void) Scrollviewdidendscrollinganimation: (Uiscrollview *) scrollview{NSLog (@" scrollviewdidendscrollinganimation "); Valid animation methods are://- (void) Setcontentoffset: (Cgpoint) Contentoffset animated: (BOOL) animated method//- (void) Scrollrecttovisible: (cgrect) rect animated: (BOOL) animated method}
//returns the UIView object that will be scaled. To execute multiple times-(uiview *) Viewforzoominginscrollview: ( Uiscrollview *) scrollview{nslog (@ " Viewforzoominginscrollview "); return self.imgview;}
//executes the method when it is about to start scaling. Once a valid scaling is performed. -(void) scrollviewwillbeginzooming:(Uiscrollview *) scrollview withview:(UIView *) view{nslog (@ " Scrollviewwillbeginzooming ")}
// 当缩放结束后,并且缩放大小回到minimumZoomScale与maximumZoomScale之间后(我们也许会超出缩放范围),调用该方法。- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale{ NSLog(@"scrollViewDidEndZooming");}
// 指示当用户点击状态栏后,滚动视图是否能够滚动到顶部。需要设置滚动视图的属性:_scrollView.scrollsToTop=YES;- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView{ return YES;}
// 当滚动视图滚动到最顶端后,执行该方法- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView{ NSLog(@"scrollViewDidScrollToTop");}
Uiscrollviewdelegate of iOS development