Use details of scrollerview, details of scrollerview

Source: Internet
Author: User

Use details of scrollerview, details of scrollerview
Method & attributes:

// Monitor the current rolling position (CGPointZero by default)

CGPoint                      contentOffset; - (void)setContentOffset:(CGPoint)contentOffset animated:(BOOL)animated;

// The size of the scroll range (CGSizeZero by default)

CGSize                       contentSize; 

// Position of the view in scrollView (UIEdgeInsetsZero)

UIEdgeInsets                 contentInset;   

// Set the Protocol

id
 
        delegate;
 

// Specify whether the control can only scroll in one direction (NO by default)

BOOL directionalLockEnabled; 

// Control whether the widget has a border bounce (YES by default)

BOOL                         bounces; 

// Control whether the border rebounded in the vertical direction (NO by default. If YES, bounces is also YES)

BOOL                         alwaysBounceVertical;  

// Control whether the border rebounded in the horizontal direction (NO by default. If YES, bounces is also YES)

BOOL                         alwaysBounceHorizontal;

// Controls whether the entire page is flipped (NO by default)

BOOL          pagingEnabled; 

// Control whether the control can scroll

BOOL          scrollEnabled;

// Controls whether a horizontal scroll bar is displayed.

BOOL                         showsHorizontalScrollIndicator; 

// Determines whether to display a scroll bar in the vertical direction.

BOOL                         showsVerticalScrollIndicator;

// Specify the position of the scroll bar in scrollerView

UIEdgeInsets                 scrollIndicatorInsets; 

// Set the scroll bar style

UIScrollViewIndicatorStyle   indicatorStyle;  
UIScrollViewDelegate
// This method is called when scrollView is rolled. This method is called when any offset value is changed. That is, during the rolling process, call multiple times-(void) scrollViewDidScroll :( UIScrollView *) scrollView {NSLog (@ "scrollViewDidScroll"); CGPoint = scrollView. contentOffset; NSLog (@ "% f, % f", point. x, point. y); // you can read the contentOffset attribute from it to determine its Scroll position. // Note: When the ContentSize attribute is smaller than the Frame value, it will not start to scroll}
// This method is called when scrollView is scaled. During the scaling process, call back multiple times-(void) scrollViewDidZoom :( UIScrollView *) scrollView {NSLog (@ "scrollViewDidScroll"); float value = scrollView. zoomScale; NSLog (@ "% f", value );}
// Execute this method when you start to scroll the view. One valid slide (start to slide, slide a short distance, as long as the fingers do not loosen, only one slide), only once. -(Void) scrollViewWillBeginDragging :( UIScrollView *) scrollView {NSLog (@ "scrollViewWillBeginDragging ");}
// Slide the scrollView and run it when the finger leaves. One valid slide, only once. // If the pagingEnabled attribute is YES, this method is not called.-(void) scrollViewWillEndDragging :( UIScrollView *) scrollView withVelocity :( CGPoint) velocity targetContentOffset :( inout CGPoint *) targetContentOffset {NSLog (@ "scrollViewWillEndDragging ");}
// Slide the view and call this method when your finger leaves the screen. One valid slide, only once. // Decelerate, which refers to whether the view will continue to scroll forward (a distance) after the finger leaves the moment. After testing, 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 );}
// Call this method when moving and slowing down. -(Void) scrollViewWillBeginDecelerating :( UIScrollView *) scrollView {NSLog (@ "scrollViewWillBeginDecelerating"); // This method is after the scrollViewDidEndDragging method .}
// This method is called when the rolling view is slowed down and stops rolling. One valid slide, only once. -(Void) initialize :( UIScrollView *) scrollView {NSLog (@ "scrollViewDidEndDecelerating"); [_ scrollView setContentOffset: CGPointMake (0,500) animated: YES];}
// Call this method after the rolling view animation is complete. If no animation is available, this method will not be called-(void) scrollViewDidEndScrollingAnimation :( UIScrollView *) scrollView {NSLog (@ "scrollViewDidEndScrollingAnimation"); // valid animation method: // (void) setContentOffset :( CGPoint) contentOffset animated :( BOOL) animated method //-(void) scrollRectToVisible :( CGRect) rect animated :( BOOL) animated method}
// Return the UIView object to be scaled. Execute multiple times-(UIView *) viewForZoomingInScrollView :( UIScrollView *) scrollView {NSLog (@ "viewForZoomingInScrollView"); return self. imgView ;}
// Execute this method when you want to start scaling. One effective scaling is performed only once. -(Void) scrollViewWillBeginZooming :( UIScrollView *) scrollView withView :( UIView *) view {NSLog (@ "scrollViewWillBeginZooming ");}
// Call this method when the scaling ends and the scaling returns to the minimumZoomScale and maximumZoomScale (we may be out of the scaling range. -(Void) scrollViewDidEndZooming :( UIScrollView *) scrollView withView :( UIView *) view atScale :( float) scale {NSLog (@ "scrollViewDidEndZooming ");}
// Indicates whether the scroll view can scroll to the top when you click the status bar. You need to set the attributes of the rolling view: _ scrollView. scrollsToTop = YES;-(BOOL) scrollViewShouldScrollToTop :( UIScrollView *) scrollView {return YES ;}
// When the scroll view is scroll to the top, execute this method-(void) scrollViewDidScrollToTop :( UIScrollView *) scrollView {NSLog (@ "scrollViewDidScrollToTop ");}
Tip: determines whether uiscrollview is scroll up or down
Int _ lastPosition; // A variable define in headfile-(void) scrollViewDidScroll :( UIScrollView *) scrollView {int currentPostion = scrollView. contentOffset. y; if (currentPostion-_ lastPosition> 25) {_ lastPosition = currentPostion; NSLog (@ "ScrollUp now");} else if (_ lastPosition-currentPostion> 25) {_ lastPosition = currentPostion; NSLog (@ "ScrollDown now") ;}// 25 can be any number and can be set as needed.
// Upgraded version: it does not rebound when it reaches the top or bottom-(void) scrollViewDidScroll :( UIScrollView *) scrollView {int currentPostion = scrollView. contentOffset. y; if (currentPostion-_ lastPosition> 20 & currentPostion> 0) {// Add currentPostion> 0 to this place.) _ lastPosition = currentPostion; NSLog (@ "ScrollUp now");} else if (_ lastPosition-currentPostion> 20) & (currentPostion <= scrollView. contentSize. height-scrollView.bounds.size.height-20) {_ lastPosition = currentPostion; NSLog (@ "ScrollDown now ");}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.