FreeRDP
Loading...
Searching...
No Matches
EditSelectionTableViewCell.m
1/*
2 Custom table cell with a label on the right, showing the current selection
3
4 Copyright 2013 Thincast Technologies GmbH, Author: Martin Fleisz
5
6 This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
7 If a copy of the MPL was not distributed with this file, You can obtain one at
8 http://mozilla.org/MPL/2.0/.
9 */
10
11#import "EditSelectionTableViewCell.h"
12
13@interface EditSelectionTableViewCell (Private)
14- (void)updateContent;
15@end
16
17@implementation EditSelectionTableViewCell
18
19@synthesize title = _title, value = _value, enabled = _enabled;
20
21- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
22{
23 self = [super initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuseIdentifier];
24 if (self)
25 {
26 // Initialization code
27 _enabled = YES;
28 [self setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
29 }
30
31 return self;
32}
33
34- (void)dealloc
35{
36 [_title release];
37 [_value release];
38 [super dealloc];
39}
40
41- (void)prepareForReuse
42{
43 [super prepareForReuse];
44
45 [_title release];
46 _title = nil;
47 [_value release];
48 _value = nil;
49 _enabled = YES;
50 [self setSelectionStyle:UITableViewCellSelectionStyleDefault];
51 [self updateContent];
52}
53
54- (void)setTitle:(NSString *)title
55{
56 if (_title != title)
57 {
58 [_title release];
59 _title = [title copy];
60 }
61
62 [self updateContent];
63}
64
65- (void)setValue:(NSString *)value
66{
67 if (_value != value)
68 {
69 [_value release];
70 _value = [value copy];
71 }
72
73 [self updateContent];
74}
75
76- (void)setEnabled:(BOOL)enabled
77{
78 _enabled = enabled;
79 [self updateContent];
80}
81
82- (void)updateContent
83{
84 UIListContentConfiguration *content = [self defaultContentConfiguration];
85 [content setText:_title];
86 [content setSecondaryText:_value];
87 if (!_enabled)
88 {
89 [[content textProperties] setColor:[UIColor tertiaryLabelColor]];
90 [[content secondaryTextProperties] setColor:[UIColor tertiaryLabelColor]];
91 }
92
93 [self setContentConfiguration:content];
94}
95
96@end