Common iOS controls-UIScrollView and ios-uiscrollview

Source: Internet
Author: User

Common iOS controls-UIScrollView and ios-uiscrollview

I. common attributes

@ Property (nonatomic) CGPoint contentOffset; // record the scroll position of UIScrollView
@ Property (nonatomic) CGSize contentSize; // content size (scroll range)
@ Property (nonatomic) UIEdgeInsets contentInset; // an additional scrolling area (four edges on top, bottom, and left)
@ Property (nonatomic, assign) id <UIScrollViewDelegate> delegate;
@ Property (nonatomic) BOOL bounces; // whether the spring effect exists
@ Property (nonatomic) BOOL showsHorizontalScrollIndicator; // whether the horizontal scroll bar is displayed
@ Property (nonatomic) BOOL showsVerticalScrollIndicator; // whether to display the vertical scroll bar


// Master contentSize, contentOffset, and delegate

 


2. Pinch gesture Scaling

1. Detailed description of Scaling Principle
1> when you try to scale UIScrollView, UIScrollView will try to send a message to its delegate (proxy object) asking which child control to zoom in.
2> In other words, UIScrollView will try to call a method of delegate and ask which sub-control is to be scaled. the return value of this method is the sub-control to be scaled.

2. Zoom principle Summary
1> UIScrollView first sets the delegate object
2> UIScrollView must know which method of delegate is used to return the child control to be scaled. delegate must implement the method of returning the child control to be scaled.
3> UIScrollView should negotiate with the delegate object: Which method should be used to return the child control to be scaled?
4> the method for returning the child control to be scaled is:

-(UIView *) viewForZoomingInScrollView :( UIScrollView *) scrollView;

3. General scaling steps (for example, zooming UIScrollView UIImageView)
1> set the delegate of UIScrollView to Controller (self)
2> the Controller complies with the UIScrollViewDelegate protocol <UIScrollViewDelegate>
3> controller implementation-(UIView *) viewForZoomingInScrollView: method, return the child control to be scaled
4> set the maximum and minimum scaling ratios.

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.