Agent for IOS ScrollView

Source: Internet
Author: User

Copyright (c) 2015 李杨. All rights reserved.

//

#import "ViewController.h"

@interface Viewcontroller () <UIScrollViewDelegate>

@property (Weak, nonatomic) Iboutlet Uiimageview *imageview;

@property (Weak, nonatomic) Iboutlet Uiscrollview *scrollview;

@end

@implementation Viewcontroller

-(void) Viewdidload {

[Super Viewdidload];

Set scrolling Area

Self.scrollView.contentSize = self.imageView.frame.size;

To set the ScrollView agent when the controller

Self.scrollView.delegate =self;

Set the zoom ratio

Self.scrollView.maximumZoomScale = 2;

Self.scrollView.minimumZoomScale = 0.5;

}

The agent that sets ScrollView is the controller

Let the controller comply with the proxy protocol

Implement methods to listen for agents

The method needs to return a ScrollView child view that tells ScrollView which view to scale

-(UIView *) Viewforzoominginscrollview: (Uiscrollview *) scrollview{

return self.imageview;

}

This method is called when the user starts dragging and dropping the image.

-(void) scrollviewwillbegindragging: (Uiscrollview *) scrollview{

NSLog (@ "%s", __func__);

}

This method is called when the Contentoffset in the ScrollView is changed.

-(void) Scrollviewdidscroll: (Uiscrollview *) scrollview{

NSLog (@ "%s", __func__);

}

This method is called when the user's finger is lifted

-(void) scrollviewdidenddragging: (Uiscrollview *) ScrollView willdecelerate: (BOOL) decelerate{

NSLog (@ "%s", __func__);

}

@end

Agent for IOS ScrollView

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.