Repository navigation
Expand file tree
/
Copy pathIFButtonCellController.m
More file actions
executable file
·112 lines (94 loc) · 2.54 KB
/
Copy pathIFButtonCellController.m
File metadata and controls
executable file
·112 lines (94 loc) · 2.54 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//
// IFButtonCellController.m
// Thunderbird
//
// Created by Craig Hockenberry on 1/29/09.
// Copyright 2009 The Iconfactory. All rights reserved.
//
#import "IFButtonCellController.h"
#import "IFControlTableViewCell.h"
@implementation IFButtonCellController
@synthesize textAlignment;
@synthesize accessoryType;
@synthesize accessoryView;
//
// init
//
// Init method for the object.
//
- (id)initWithLabel:(NSString *)newLabel withAction:(SEL)newAction onTarget:(id)newTarget;
{
self = [super init];
if (self != nil)
{
label = newLabel;
action = newAction;
target = newTarget;
textAlignment = NSTextAlignmentCenter;
accessoryType = UITableViewCellAccessoryNone;
}
return self;
}
- (id)initWithLabel:(NSString *)newLabel withAccessoryView:(UIView *)newAccessoryView withAction:(SEL)newAction onTarget:(id)newTarget
{
self = [self initWithLabel:newLabel withAction:newAction onTarget:newTarget];
if (self != nil) {
accessoryView = newAccessoryView;
}
return self;
}
//
// dealloc
//
// Releases instance memory.
//
//
// tableView:didSelectRowAtIndexPath:
//
// Handle row selection
//
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (accessoryType != UITableViewCellAccessoryDetailDisclosureButton)
{
if (target && [target respondsToSelector:action])
{
[target performSelector:action withObject:self];
}
[tableView deselectRowAtIndexPath:indexPath animated:YES];
}
}
//
// tableView:cellForRowAtIndexPath:
//
// Returns the cell for a given indexPath.
//
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellIdentifier = @"ButtonDataCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}
cell.textLabel.text = label;
cell.accessoryType = accessoryType;
//cell.target = target;
//cell.accessoryAction = action;
if (accessoryType == UITableViewCellAccessoryDetailDisclosureButton)
{
cell.selectionStyle = UITableViewCellSelectionStyleNone;
cell.textLabel.textAlignment = textAlignment;
}
else
{
// NOTE: In the 2.2 firmware, the alignment of the text on the button is wrong. Since the problem was
// only visual and was fixed in the 2.2.1 firmware, we're just going live with it.
cell.textLabel.textAlignment = textAlignment;
}
if (accessoryView) {
cell.accessoryView = accessoryView;
}
return cell;
}
@end