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.