This repository has been archived by the owner on May 8, 2020. It is now read-only.
/
DTGridViewCell.m
76 lines (56 loc) · 1.55 KB
/
DTGridViewCell.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
70
71
72
73
74
75
76
//
// DTGridViewCell.m
// GridViewTester
//
// Created by Daniel Tull on 06.04.2009.
// Copyright 2009 Daniel Tull. All rights reserved.
//
#import "DTGridViewCell.h"
#import "DTGridView.h"
#pragma mark Private Methods
@interface DTGridViewCell ()
- (DTGridView *)gridView;
@end
@implementation DTGridViewCell
@synthesize xPosition, yPosition, identifier, delegate, selected;
@synthesize highlighted;
@dynamic frame;
- (id)initWithReuseIdentifier:(NSString *)anIdentifier {
if (![super initWithFrame:CGRectZero])
return nil;
identifier = [anIdentifier copy];
return self;
}
- (void)dealloc {
[identifier release];
[super dealloc];
}
- (void)awakeFromNib {
identifier = nil;
}
- (void)prepareForReuse {
self.selected = NO;
self.highlighted = NO;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
self.highlighted = YES;
[super touchesEnded:touches withEvent:event];
}
- (void)touchesCancelled:(NSSet *)touches withEvent:(UIEvent *)event {
self.highlighted = NO;
[super touchesCancelled:touches withEvent:event];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
self.highlighted = NO;
[[self gridView] selectRow:self.yPosition column:self.xPosition scrollPosition:DTGridViewScrollPositionNone animated:YES];
[self.delegate gridViewCellWasTouched:self];
[super touchesEnded:touches withEvent:event];
}
#pragma mark -
#pragma mark Private Methods
- (DTGridView *)gridView {
UIResponder *r = [self nextResponder];
if (![r isKindOfClass:[DTGridView class]]) return nil;
return (DTGridView *)r;
}
@end