The use of iOS UIScrollView proxy and several methods of listening in the scaling age, iosuiscrollview
There must be at least three steps:
I. Implementation Protocol
2. Establish relationships
3. Set the scaling range
For details, see the code:
# Import "ViewController. h "@ interface ViewController () <UIScrollViewDelegate> // you must first comply with this Protocol @ property (weak, nonatomic) IBOutlet UIScrollView * ScrollView; @ property (weak, nonatomic) IBOutlet UIImageView * minionPic; @ end @ implementation ViewController // This method is always called during the rolling process-(void) scrollViewDidScroll :( UIScrollView *) scrollView {// NSLog (@ "scrollViewDidScroll");} // call this method when rolling starts. Drag it once, this method is called only once and is called once at the beginning-(void) scrol LViewWillBeginDragging :( UIScrollView *) scrollView {// NSLog (@ "scrollViewWillBeginDragging");} // events to be triggered when a user starts scaling actions-(void) Events :( UIScrollView *) scrollView withView :( UIView *) view {NSLog (@ "scrollViewWillBeginZooming") ;}// which View should be set to bloom when the user scales? -(UIView *) viewForZoomingInScrollView :( UIScrollView *) scrollView {return self. minionPic;}-(void) viewDidLoad {[super viewDidLoad]; // set the content size of ScrollView contentSize self. scrollView. contentSize = self. minionPic. frame. size; // bind a proxy to establish the relationship between the ScrollView and proxy self. scrollView. delegate = self; // you can specify the zooming range as self. scrollView. minimumZoomScale = 0.2; self. scrollView. maximumZoomScale = 2.0; // Do any additional setup after loading the view, typically from a nib .} -(void) didReceiveMemoryWarning {[super didreceivemorywarning]; // Dispose of any resources that can be recreated .} @ end