How to use Uiscrollview in detail

Source: Internet
Author: User



The default Cgpointzero, which is used to set the ScrollView scroll offset.

Set the scroll offset of the ScrollView

Scrollview.contentoffset = Cgpointmake (0, 200);


Default Cgsizezero, used to set the scroll range of the ScrollView.

Set the scroll range for ScrollView

Scrollview.contentsize = Cgsizemake (Self.view.bounds.size.width, Self.view.bounds.size.height * 2);


The default Uiedgeinsetszero, which is used to set the additional scrolling area of the ScrollView.

Set the extra top scrolling area of the ScrollView: (Uiedgeinsetsmake is set counterclockwise, upper left and right)

Scrollview.contentinset = uiedgeinsetsmake (100, 0, 0, 0);


The default is yes to set the spring effect of the ScrollView

Cancels the spring effect of ScrollView

Scrollview.bounces = NO;


The default is no, which sets ScrollView whether to turn on paging.

Turn on paging

scrollview.pagingenabled = YES;


The default is yes to set whether ScrollView allows scrolling.

ScrollView No scrolling

scrollview.scrollenabled = NO;


The default is yes to set whether the ScrollView displays a horizontal scroll bar.

Hide Horizontal scroll bar

Scrollview.showshorizontalscrollindicator = NO;


The default is yes to set whether the ScrollView displays a vertical scroll bar.

Hide vertical scroll bars

Scrollview.showsverticalscrollindicator = NO;


Default 1.0, which is used to set the ScrollView minimum scale reduction.

Set ScrollView to allow the maximum magnification of a child view

Scrollview.maximumzoomscale = 2;


Default 1.0, which sets the maximum magnification for scrollview.

Set ScrollView to allow the minimum scale of the child view

Scrollview.minimumzoomscale = 0.8;


class to comply with the Uiscrollviewdelegate protocol

Scrollview.delegate = self; Declaring ScrollView's agent is me, this method is in uiscrollviewdelegate, so we're going to abide by the Uiscrollviewdelegate protocol.

11.1 This method is called when the offset of scrollview is changed, that is, the rolling ScrollView is called.

-(void) Scrollviewdidscroll: (Uiscrollview *) ScrollView;

11.2 This method is called when ScrollView is scaled.

-(void) Scrollviewdidzoom: (Uiscrollview *) ScrollView Ns_available_ios (3_2);

11.3 will be called when dragging.

-(void) scrollviewwillbegindragging: (Uiscrollview *) ScrollView;

11.4 Call when you are about to stop dragging

-(void) scrollviewwillenddragging: (Uiscrollview *) ScrollView withvelocity: (cgpoint) Velocity targetcontentoffset: ( InOut cgpoint *) Targetcontentoffset Ns_available_ios (5_0);

11.5 Call when dragging is stopped.

-(void) scrollviewdidenddragging: (Uiscrollview *) ScrollView willdecelerate: (BOOL) decelerate;

11.6 will be called when the deceleration is complete.

-(void) scrollviewwillbegindecelerating: (Uiscrollview *) ScrollView;

11.7 When the deceleration is complete, call

-(void) scrollviewdidenddecelerating: (Uiscrollview *) ScrollView;

11.8 Returns the view that needs to be scaled, which must be a child view in the ScrollView.

-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) ScrollView;


-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) ScrollView


return scrollview.subviews[0];


11.9 ScrollView about to start scaling

-(void) scrollviewwillbeginzooming: (Uiscrollview *) ScrollView Withview: (UIView *) View Ns_available_ios (3_2);

11.10 ScrollView Complete Zoom

-(void) scrollviewdidendzooming: (Uiscrollview *) ScrollView Withview: (UIView *) View Atscale: (float) scale;

11.11 when paging is not turned on, the proxy method call order:

Scrollviewwillbegindragging–> Scrollviewdidscroll, scrollviewwillenddragging, scrollViewDidEndDragging

11.12 Proxy method Invocation order when paging is turned on

Scrollviewwillbegindragging, Scrollviewdidscroll, scrollviewdidenddragging, Scrollviewwillbegindecelerating->scrollviewdidscroll-Scrollviewdidenddecelerating


Specifies whether the control can scroll only in one Direction


Change the position of the deceleration point of the Scrollerview


Monitor whether the current target is being tracked


Change the position of the deceleration point of the Scrollerview


Controls whether the view is delayed call to start scrolling method


Controls whether the control touches an event that cancels the touch


Set the style of the scroll bar


Monitor whether the current target is slowing down

How to use Uiscrollview in detail

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: 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.