iOS Common Controls-uiscrollview

Source: Internet
Author: User

One, Common Properties

@property (nonatomic) cgpoint contentoffset;                     //record uiscrollview scrolling position
@property (nonatomic) cgsize contentsize;                          //content size ( The range that can be scrolled)
@property (nonatomic) uiedgeinsets contentinset;                //Additional scrolling area (4 edges up or down)
@property (nonatomic, assign) id< Uiscrollviewdelegate> delegate;
@property (nonatomic) BOOL bounces;                                  //have spring effect
@property (Nonatomi c) BOOL showshorizontalscrollindicator; //whether to display the horizontal scrollbar
@property (nonatomic) bool Showsverticalscrollindicator ;      whether to display the vertical scroll bar


Focus on mastering Contentsize, Contentoffset, delegate


Second, pinch gesture zoom

1. Detailed Scaling principle
1> when the user attempts to scale the Uiscrollview, Uiscrollview tries to send a message to his delegate (proxy object) asking which child control to scale.
2> in other words, that is, Uiscrollview tries to call a method of delegate, asking which child control to scale, and the return value of the method is the child control that needs to be scaled.

2. Summary of Scaling principle
1> Uiscrollview Set Delegate object first
2> Uiscrollview must know which method delegate returns the child controls that need to be scaled, and delegate must implement the method that returns the child controls that need to be scaled.
3> Uiscrollview to negotiate with delegate object: Which method returns the child controls that need to be scaled?
4> the method that returns a child control that needs to be scaled is:

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

3. General implementation steps for scaling (such as scaling Uiscrollview internal Uiimageview)
1> setting the delegate of the Uiscrollview as the Controller (self)
2> Controller complies with Uiscrollviewdelegate protocol <UIScrollViewDelegate>
3> Controller Implementation-(UIView *) Viewforzoominginscrollview: Method, returns the child controls that need to be scaled
4> setting the maximum and minimum zoom ratios

iOS Common Controls-uiscrollview

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.