Learning from IOS--uiscrollview (i)

Source: Internet
Author: User

1. Why Use Uiscrollview

Because the mobile device screen size is extremely limited, so the direct display in front of the user's content is also quite limited, when the content is more than a screen, users can scroll gestures to see the content of the screen beyond the ordinary UIView does not have scrolling function, can not display too much content, Uiscrollview is a scroll-capable view control that can be used to display a large amount of content and to scroll through all of the content.

2, Uiscrollview the most commonly used for the maturity of

1) Cgpoint Contentoffset: This property is the position that represents the initial scroll of the Uiscrollview

2) Contentsize: This property is used to represent the size of the Uiscrollview content, the specific scroll range (width,height)

3) Uiedgeinsets Contentinset: This property never represents the additional scroll range of the upper and lower sides of the Uiscrollview

3. Some other properties

@property (nonatomic) BOOL bounces;

Set Uiscrollview If spring effect is required

@property (nonatomic,getter=isscrollenabled) BOOL scrollenabled;

Sets whether Uiscrollview can scroll

@property (nonatomic) BOOL showshorizontalscrollindicator;

Whether to display the horizontal scroll bar

@property (nonatomic) BOOL showsverticalscrollindicator;

Whether to show vertical scroll bars

4, the agent of Uiscrollview

1) Scrollviewwillbegindragging: Call this method when the user starts dragging

2)Scrollviewdidscroll: Call this method when you scroll to a specific location (most used)

3) Scrollviewdidenddragging:willdecelerate: Call this method when the user stops dragging

5. Code Demo

1  //Specific scrolling range2_fzhscrollview.contentsize =_fzhimageview.frame.size;3     //additional scrolling range around4_fzhscrollview.contentinset = Uiedgeinsetsmake ( -, -, -, -);5     //the initial scroll point6    //_fzhscrollview.contentoffset = Cgpointmake (ten);7     //sets whether the scroll bar is displayed8_fzhscrollview.showshorizontalscrollindicator =NO;9_fzhscrollview.showsverticalscrollindicator =NO;Ten     //Set up proxy One_fzhscrollview.Delegate= self;

6. Output Result:

2016-03-17 15:47:56.538 01-uiscrollview[4049:225106] scrollviewdidscroll2016-03-17 15:47:56.562 01-UIScrollView[ 4049:225106] scrollviewdidscroll2016-03-17 15:47:57.052 01-uiscrollview[4049:225106] ScrollViewDidScroll2016-03-17 15:47:57.060 01-uiscrollview[4049:225106] Scrollviewdidenddragging

7, Demo now address:

Https://github.com/fengzhihao123/01-UIScrollView

Learning from IOS--uiscrollview (i)

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.