The use of IOS Uiscrollview Agent and several methods of agent monitoring during scaling

Source: Internet
Author: User

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

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.