forked from coding/Coding-iOS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSettingTextCell.m
More file actions
executable file
·67 lines (56 loc) · 1.85 KB
/
SettingTextCell.m
File metadata and controls
executable file
·67 lines (56 loc) · 1.85 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
//
// SettingTextCell.m
// Coding_iOS
//
// Created by 王 原闯 on 14-10-13.
// Copyright (c) 2014年 Coding. All rights reserved.
//
#import "SettingTextCell.h"
@interface SettingTextCell ()
@end
@implementation SettingTextCell
- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
if (!_textField) {
_textField = [[UITextField alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 7,kScreen_Width- 2*kPaddingLeftWidth, 30)];
_textField.backgroundColor = [UIColor clearColor];
_textField.font = [UIFont systemFontOfSize:16];
_textField.textColor = [UIColor blackColor];
_textField.clearButtonMode = UITextFieldViewModeWhileEditing;
_textField.placeholder = @"未填写";
[_textField addTarget:self action:@selector(textValueChanged:) forControlEvents:UIControlEventEditingChanged];
[self.contentView addSubview:_textField];
}
}
return self;
}
- (void)awakeFromNib {
// Initialization code
}
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
// Configure the view for the selected state
}
- (void)setTextValue:(NSString *)textValue andTextChangeBlock:(void(^)(NSString *textValue))block{
[_textField becomeFirstResponder];
if ([textValue isEqualToString:@"未填写"]) {
_textValue = nil;
}else{
_textValue = textValue;
}
_textChangeBlock = block;
}
- (void)layoutSubviews{
[super layoutSubviews];
_textField.text = _textValue;
}
- (void)textValueChanged:(UITextField *)sender{
_textValue = sender.text;
if (_textChangeBlock) {
_textChangeBlock(_textValue);
}
}
@end