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