Case: (Hold down the option key in the simulator and the zoom gesture will appear when you click the mouse)
(1) in VIEWCONTROLLER.M:
--scaling things is uiscrollview in addition to scrolling there is a function, so the need to scale things should be placed in the Uiscrollview first. For example here ImageView;
--And when we zoom in, scrollview ourselves don't know which control we want to scale, so ScrollView needs an agent to tell it. This agent is generally our controller;
--and the controller must obey its protocol to become its agent.
--After the Controller accepts the protocol, it can call this method to tell ScrollView which control needs to be scaled;
--and at this point can not be scaled, because our scrollview maximum minimum scale is not set, scaling without boundaries will be a big deal.
#import "ViewController.h" @interface Viewcontroller () <uiscrollviewdelegate>//first step, comply with protocol @property (weak, nonatomic) Iboutlet Uiscrollview *scrollview; @property (weak, nonatomic) Iboutlet Uiimageview *imageview;@ End@implementation viewcontroller-(void) viewdidload { //self.scrollview.contentsize=cgsizemake (892, 632); Self.scrollview.contentsize=self.imageview.frame.size; Sets the maximum minimum scale for scaling self.scrollview.maximumzoomscale=2.0; self.scrollview.minimumzoomscale=0.2; Set Uiscrollview agent self.scrollview.delegate=self;//the second step. Set yourself up as an agent [Super Viewdidload]; Do any additional setup after loading the view, typically from a nib.} To implement this method, the fact that the agent has to do is to return the control to be scaled to scrollView himself-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) scrollview{ return Self.imageview;} @end
(2) How to mimic the zoom gesture in the simulator?
Hold down the option key. Zoom gestures appear when you click the mouse, and drag is equivalent to zooming.
(3) Description
Agent, the most critical data is listening.
That is, what happens to this control, it is generally possible to notify the agent directly. The agent can know the first time. And the agent can respond accordingly.
Of course. Some of the methods in this agreement must be implemented, that is, selective implementation.
"iOS Dev-54" Case Study: Practice the detailed implementation of the proxy mode with the Uiscrollview zoom picture function