IOS----Uiscrollview

Source: Internet
Author: User

UiscrollviewWhat is Uiscrollview
    • The screen size of mobile devices is extremely limited, so the content directly displayed in front of the user is also quite limited
    • When more content is displayed than a screen, users can scroll to see what's outside of the screen
    • The normal UIView does not have scrolling function and cannot display too much content.
    • Uiscrollview is a scroll-capable view control that can be used to display a large amount of content, and can be scrolled to see all the content
The basic use of Uiscrollview Uiscrollview is simple: add what you need to show to Uiscrollview, and set the Contentsize property of Uiscrollview. Tell Uiscrollview the size of all the content, that is to tell it to scroll the Range Uiscrollview Agent (delegate)
    • Many times, we want to do some specific things when uiscrollview is scrolling or scrolling to a certain location or when scrolling is stopped.
    • To accomplish these functions, the precondition is to be able to hear the entire rolling process of the Uiscrollview
    • When Uiscrollview a series of scrolling operations, it will automatically notify its agent (delegate) object, send the corresponding message to its agent, let the agent know its scrolling situation
    • In other words, to listen to the Uiscrollview scrolling process, you must first set a proxy object to Uiscrollview, and then through the agent to know the Uiscrollview scrolling process
Communication of Uiscrollview and delegate
    • Send a specific message when the user starts dragging (call: scrollviewwillbegindragging: Method)
    • Send specific message when scrolling to a specific location (call: Scrollviewdidscroll: Method)
    • Send a specific message when the user stops dragging (call: Scrollviewdidenddragging:willdecelerate: Method)
Therefore, want to become Uiscrollview delegate, is conditional, must implement corresponding method, can monitor Uiscrollview rolling process. Uiscrollview the method that delegate needs to implement is defined in the Uiscrollviewdelegate protocol, so want to be delegate of Uiscrollview, Must abide by the Uiscrollviewdelegate protocol, and then implement the corresponding method in the protocol, you can listen to the rolling process of Uiscrollview PostScript: two objects to achieve communication, another object is required to comply with the Protocol (that is, become a proxy), the method of implementing the Protocol to the object call. The agent uses the steps: 1, the agent complies with the Agreement 2, the agent realizes the method 3, set as an agent for an object (generally using the controller as a proxy listener) (for example: self.scrollview.delegate=self;)Common Properties of Uiscrollview @property (nonatomic) cgpoint Contentoffset; This property represents the position of the Uiscrollview current scroll @property (nonatomic) cgsize Contentsize; This property is used to represent the size of the Uiscrollview content, the scrolling range @property (nonatomic) uiedgeinsets contentinset; This property is capable of adding additional scrolling areas Uiscrollview other properties @property (nonatomic) BOOL bounces in Uiscrollview four weeks, and setting Uiscrollview if the spring effect is required @ Property (nonatomic,getter=isscrollenable) bool scrollenabled; Sets whether Uiscrollview can scroll @property (nonatomic) bool Showshorizontalscrollindicator whether the horizontal scrollbar @property (nonatomic) BOOL Showsverticalscrollindicator is displayed, whether the vertical scroll bar is displayed Uiscrollview can achieve zoom functionWhen the user uses the pinch gesture in Uiscrollview, Uiscrollview sends a message to the agent asking the agent to scale which child control within itself is called the proxy-(UIView *) Viewforzoominginscrollview :(Uiscrollview *) ScrollView; Method This method returns the control that you want to scale to scale, and also to set the maximum minimum scale scale implementation step:
    • 1. Set the Id<uiscrollviewdelegate>delegate proxy object for Uiscrollview
    • 2. Set Minimumzoomscale: Minimum scale reduction
    • 3. Set Maxmumzoomscale: Maximum scale magnification
    • 4. Let the proxy object implement the following method to return the view control that needs to be scaled
-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) ScrollView; page OutAs long as the Pageenable property of the Uiscrollview is set to Yes,uiscrollview will be divided into multiple separate pages, the contents of the content will be able to be paginated display generally with the Uipagecontrol enhance the paging effect, Uipagecontrol Common properties are as follows:
    • How many pages are there?
    • @property (nonatomic) Nsinteger numberofpages;
    • The page number that is currently displayed
    • @property (nonatomic) Nsinteger currentpage;
    • Whether you need to hide the page number indicator when there is only one page
    • @property (nonatomic) BOOL hidesforsinglepage;
    • Other page number indicator color
    • @property (Nonatomic,retain) Uicolor *pageindicatortintcolor;
    • Current page number indicator color
    • @property (Nonatomic,retain) Uicolor *currentpageindicatortintcolor;
NstimerNstimer is called "Timer" and it functions as follows:
    • Perform a task at a specified time
    • Perform specified tasks at intervals
Use timer timer once stopped is equivalent to discarded, if needed again, need to re-create a timer in iOS processing UI and touch event threads are generally the main thread, if a touch event occurs when the timer is used, then the thread responds to the touch event, So if we want to handle the touch event and handle the timer, we need to set the timer priority use-(void) Invalidate method can stop the timer

IOS----Uiscrollview

Related Article

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.