-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathFTCStringCell.m
More file actions
124 lines (101 loc) · 3.76 KB
/
Copy pathFTCStringCell.m
File metadata and controls
124 lines (101 loc) · 3.76 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
113
114
115
116
117
118
119
120
121
122
123
124
//
// FTCStringCell.m
// EasyLink
//
// Created by William Xu on 14-3-25.
// Copyright (c) 2014年 MXCHIP Co;Ltd. All rights reserved.
//
#import "FTCStringCell.h"
@implementation FTCStringCell
@synthesize ftcConfig = _ftcConfig;
@synthesize contentText;
@synthesize sectionRow;
@synthesize contentRow;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.textLabel.backgroundColor = [UIColor clearColor];
}
return self;
}
- (id)delegate
{
return theDelegate;
}
- (void)setDelegate:(id)delegate
{
theDelegate = delegate;
}
- (void)awakeFromNib
{
// Initialization code
[super awakeFromNib];
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)setFtcConfig:(NSMutableDictionary *)newFtcConfig {
_ftcConfig = newFtcConfig;
NSString *contentString;
NSNumber *contentNumber;
self.textLabel.backgroundColor = [UIColor clearColor];
self.textLabel.text = [self.ftcConfig objectForKey:@"N"];
if([[self.ftcConfig objectForKey:@"C"] isKindOfClass:[NSString class]]){ //string
contentString = [self.ftcConfig objectForKey:@"C"];
self.contentText.text = contentString;
}else{ //number
contentNumber = [self.ftcConfig objectForKey:@"C"];
self.contentText.text = [contentNumber stringValue];
}
/*Readonly cell*/
if ([[self.ftcConfig objectForKey:@"P"] isEqualToString:@"RO"]) {
[self.contentText setUserInteractionEnabled:NO];
[self.contentText setTextColor:[UIColor grayColor]];
return;
}
[contentText setDelegate:self];
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
//- (IBAction)editingChanged: (UITextField *)textField
//{
// FTCStringCell *cell;
// NSIndexPath *indexPath;
// NSLog(@"Value changed!");
// cell = (FTCStringCell *)textField.superview.superview;
// indexPath = [configTableView indexPathForCell:cell];
// NSUInteger sectionRow = [ indexPath indexAtPosition: 0 ]-hasOTA;
// NSUInteger contentRow = [ indexPath indexAtPosition: 1 ];
// NSArray *array =[[self.configMenu objectAtIndex:sectionRow] objectForKey:@"C"];
// NSMutableDictionary *content = [array objectAtIndex: contentRow];
// NSMutableDictionary *updateSetting = [self.configData objectForKey:@"update"];
// if([[content objectForKey:@"C"] isKindOfClass:[NSString class]])
// [updateSetting setObject:textField.text forKey:[content objectForKey:@"N"]];
// else{
// NSInteger value = [textField.text intValue];
// [updateSetting setObject:[NSNumber numberWithLong:value] forKey:[content objectForKey:@"N"]];
// }
//}
//- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
// //Replace the string manually in the textbox
// textField.text = [textField.text stringByReplacingCharactersInRange:range withString:string];
// //perform any logic here now that you are sure the textbox text has changed
// //[self didChangeTextInTextField:textField];
// NSLog(@"Value changed!");
// return NO; //this make iOS not to perform any action
//}
- (IBAction)editingChanged: (UITextField *)textField
{
NSIndexPath *indexpath = [NSIndexPath indexPathForRow:contentRow inSection:sectionRow];
if( [theDelegate respondsToSelector:@selector(editingChanged:AtIndexPath:)]){
[theDelegate performSelector:@selector(editingChanged:AtIndexPath:) withObject:textField.text withObject:indexpath];
}
}
@end