"iOS Dev-54" Case Study: Practice the detailed implementation of the proxy mode with the Uiscrollview zoom picture function

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.