-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathFTCStringSelectCell.m
More file actions
91 lines (77 loc) · 2.75 KB
/
Copy pathFTCStringSelectCell.m
File metadata and controls
91 lines (77 loc) · 2.75 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
//
// FTCStringSelectCell.m
// MICO
//
// Created by William Xu on 14-4-8.
// Copyright (c) 2014年 MXCHIP Co;Ltd. All rights reserved.
//
#import "FTCStringSelectCell.h"
@implementation FTCStringSelectCell
@synthesize ftcConfig = _ftcConfig;
@synthesize contentText;
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}
- (void)awakeFromNib
{
// Initialization code
[super awakeFromNib];
}
- (id)delegate
{
return theDelegate;
}
- (void)setDelegate:(id)delegate
{
theDelegate = delegate;
}
- (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.text = [self.ftcConfig objectForKey:@"N"];
if([[self.ftcConfig objectForKey:@"T"] isEqualToString:@"string"]){ //string
contentString = [self.ftcConfig objectForKey:@"C"];
if([self.textLabel.text isEqualToString:@"Device Name"]){
NSRange range = [contentString rangeOfCharacterFromSet:[NSCharacterSet characterSetWithCharactersInString:@"#"]
options:NSBackwardsSearch];
if(range.location == NSNotFound){
nameSuffix = nil;
range.length = [contentString length];
}else{
range.length = [contentString length] - range.location;
nameSuffix = [contentString substringWithRange:range];
range.length = range.location;
}
range.location = 0;
self.contentText.text = [contentString substringWithRange:range];
}else{
self.contentText.text = contentString;
}
}else{ //number
contentNumber = [self.ftcConfig objectForKey:@"C"];
self.contentText.text = [contentNumber stringValue];
}
[self.contentText setUserInteractionEnabled:NO];
[self.contentText setTextColor:[UIColor grayColor]];
return;
}
- (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
}
@end