There must be at least three steps:
One, the implementation of the Protocol
Second, establish a relationship
Three, set the range of the zoom
See the code for details:
#import "ViewController.h" @interface Viewcontroller () <UIScrollViewDelegate>//must first comply with this agreement @property (weak, nonatomic) Iboutlet Uiscrollview *scrollview; @property (weak, nonatomic) Iboutlet Uiimageview *minionpic;@ End@implementation viewcontroller//during scrolling, the method is always called-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{//NSLog (@ "Scrollviewdidscroll");} This method is called when scrolling is started, and is only called once and is called once for the initial start-(void) scrollviewwillbegindragging: (Uiscrollview *) scrollview{//nslog (@ " Scrollviewwillbegindragging ");} Event that the agent will fire when the user starts scaling the action-(void) scrollviewwillbeginzooming: (Uiscrollview *) ScrollView Withview: (UIView *) view{NSLog (@ " Scrollviewwillbeginzooming ");} When the user zooms, which view should be set to bloom? -(UIView *) Viewforzoominginscrollview: (Uiscrollview *) scrollview{return self.minionpic;} -(void) viewdidload {[Super viewdidload]; Sets the content size of ScrollView contentsize self. Scrollview.contentsize= self.minionPic.frame.size; Binding agent, establish the relationship between ScrollView and agent self. Scrollview.delegate = self; Set the range of scaling 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 didreceivememorywarning]; Dispose of any resources the can be recreated.} @end
The use of IOS Uiscrollview Agent and several methods of agent monitoring during scaling