Use of iOS UIScrollView proxy and several methods of listening in the scaling age
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 ()
// Comply with this Protocol First @ 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 you start to scroll. When you drag it once, this method is called only once and is called once at the beginning-(void) scrollViewWillBeginDragging :( UIScrollView *) scrollView {// NSLog (@ "scrollViewWillBeg InDragging ");} // the event to be triggered when a user starts scaling actions-(void) scrollViewWillBeginZooming :( 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