forked from rpetrich/AppList
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ALValueCell.m
65 lines (49 loc) · 1.37 KB
/
ALValueCell.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
#import "ALValueCell.h"
@implementation ALValueCell
@synthesize delegate;
- (void)loadValue:(id)value
{
}
- (void)didSelect
{
}
@end
@implementation ALSwitchCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
if ((self = [super initWithStyle:style reuseIdentifier:reuseIdentifier])) {
switchView = [[UISwitch alloc] initWithFrame:CGRectZero];
[switchView addTarget:self action:@selector(valueChanged) forControlEvents:UIControlEventValueChanged];
[self setAccessoryView:switchView];
}
return self;
}
- (void)dealloc
{
[switchView release];
[super dealloc];
}
@synthesize switchView = _switchView;
- (void)loadValue:(id)value
{
switchView.on = [value boolValue];
}
- (void)valueChanged
{
id value = [NSNumber numberWithBool:switchView.on];
[[self delegate] valueCell:self didChangeToValue:value];
}
@end
@implementation ALCheckCell
- (void)loadValue:(id)value
{
[self setAccessoryType:[value boolValue] ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone];
}
- (void)didSelect
{
UITableViewCellAccessoryType type = [self accessoryType];
[self setAccessoryType:(type == UITableViewCellAccessoryNone) ? UITableViewCellAccessoryCheckmark : UITableViewCellAccessoryNone];
id value = [NSNumber numberWithBool:type == UITableViewCellAccessoryNone];
[[self delegate] valueCell:self didChangeToValue:value];
}
@end