-
Notifications
You must be signed in to change notification settings - Fork 0
/
BadgeImageView.m
69 lines (54 loc) · 1.6 KB
/
BadgeImageView.m
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
60
61
62
63
64
65
66
67
68
69
//
// BadgeImageView.m
// ImIn
//
// Created by Myungjin Choi on 11. 2. 21..
// Copyright 2011 KTH. All rights reserved.
//
#import "BadgeImageView.h"
#import "BadgeDetailView.h"
#define DOUBLE_TAP_DELAY 0.35
@interface BadgeImageView ()
- (void)handleSingleTap;
- (void)handleDoubleTap;
@end
@implementation BadgeImageView
//@synthesize delegate;
@synthesize badgeData;
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setUserInteractionEnabled:YES];
[self setMultipleTouchEnabled:NO];
}
return self;
}
- (void) awakeFromNib {
[self setUserInteractionEnabled:YES];
[self setMultipleTouchEnabled:NO];
}
- (void) dealloc {
[badgeData release];
[super dealloc];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
tapLocation = [touch locationInView:self];
if ([touch tapCount] == 1) {
[self performSelector:@selector(handleSingleTap) withObject:nil afterDelay:DOUBLE_TAP_DELAY];
} else if([touch tapCount] == 2) {
[self handleDoubleTap];
}
}
#pragma mark Private
- (void)handleSingleTap {
CGPoint centerPoint = [self.superview convertPoint:self.center toView:nil];
NSValue* center = [NSValue valueWithCGPoint:centerPoint];
NSMutableDictionary* aData = [NSMutableDictionary dictionaryWithDictionary:badgeData];
[aData addEntriesFromDictionary:[NSDictionary dictionaryWithObjectsAndKeys:center, @"startPoint", nil]];
[[NSNotificationCenter defaultCenter] postNotificationName:BADGE_IMAGE_TAPPED_NOTIFICATION object:self userInfo:aData];
}
- (void)handleDoubleTap {
}
@end