-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMapView.m
More file actions
executable file
·59 lines (52 loc) · 1.37 KB
/
Copy pathMapView.m
File metadata and controls
executable file
·59 lines (52 loc) · 1.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// MapView.m
// MapView
//
// Created by Junfeng Shen on 16/2/12.
// Copyright (c) 2012 SYSU. All rights reserved.
//
#import "MapView.h"
#import "PinView.h"
@implementation MapView
@synthesize imageView;
- (id) initWithFrame:(CGRect)frame{
if(self = [super initWithFrame:frame]){
self.delegate = self;
self.showsVerticalScrollIndicator = NO;
self.showsHorizontalScrollIndicator = NO;
}
return self;
}
- (void) setUp:(UIImage*)map{
self.imageView = [[UIImageView alloc] initWithImage:map];
self.imageView.userInteractionEnabled = YES;
self.imageView.contentMode = UIViewContentModeCenter;
self.maximumZoomScale = 2.0;
self.minimumZoomScale = MIN(320.0/map.size.width, 480.0/map.size.height);
self.zoomScale = self.minimumZoomScale;
[self addSubview:self.imageView];
}
- (void)layoutSubviews{
[super layoutSubviews];
UIView* imgV = [self.delegate viewForZoomingInScrollView:self];
CGFloat svw = self.bounds.size.width;
CGFloat svh = self.bounds.size.height;
CGFloat vw = imgV.frame.size.width;
CGFloat vh = imgV.frame.size.height;
CGRect f = imgV.frame;
if(vw < svw)
f.origin.x = (svw - vw) / 2.0;
else f.origin.x = 0;
if(vh < svh)
f.origin.y = (svh - vh) / 2.0;
else f.origin.y = 0;
imgV.frame = f;
}
- (UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView{
return imageView;
}
- (void) dealloc{
[self.imageView release];
[super dealloc];
}
@end