forked from dmorrow/ObjectiveC-Utils
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUTTableViewCell.m
96 lines (73 loc) · 1.46 KB
/
UTTableViewCell.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// UTTableViewCell.m
// RingFinder
//
// Created by Danny Morrow on 10/29/10.
// Copyright 2010 unitytheory.com. All rights reserved.
//
#import "UTTableViewCell.h"
@implementation UTTableViewCell
@synthesize key = _key;
@synthesize value = _value;
@synthesize data = _data;
@synthesize delegate;
+ (CGFloat)tableView:(UITableView*)tableView rowHeightForObject:(id)object
{
return tableView.rowHeight;
}
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])
{
[self drawView];
}
return self;
}
- (void) drawView
{
}
- (void) select
{
}
-(UIResponder *) responder
{
return nil;
}
- (void) setValue:(id)val
{
if (_value != val)
{
_value = val;
if ([self.delegate respondsToSelector:@selector(valueDidChange:value:key:)])
{
[self.delegate valueDidChange:self value:val key:self.key];
}
}
}
- (UIViewController*) viewController
{
for (UIView* next = [self superview]; next; next = next.superview)
{
UIResponder* nextResponder = [next nextResponder];
if ([nextResponder isKindOfClass:[UIViewController class]])
{
return (UIViewController*)nextResponder;
}
}
return nil;
}
- (void) setData:(NSDictionary *)d
{
if (_data != d)
{
_data = d;
self.textLabel.text = [_data valueForKey:@"Title"];
self.key = [_data valueForKey:@"Key"];
}
}
- (void) dealloc
{
self.delegate = nil;
self.value = nil;
}
@end