11
11
#import " TPKeyboardAvoidingTableView.h"
12
12
#import " Coding_NetAPIManager.h"
13
13
#import " ProjectTag.h"
14
+ #import " EditColorViewController.h"
14
15
15
16
#define kCellIdentifier_ResetLabelCell @" ResetLabelCell"
16
17
17
18
@interface ResetLabelViewController () <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>
18
- {
19
- NSString *_tempStr;
20
- }
19
+ @property (strong , nonatomic ) NSString *tempStr;
20
+
21
21
@property (strong , nonatomic ) TPKeyboardAvoidingTableView *myTableView;
22
22
23
23
@property (nonatomic , weak ) UITextField *mCurrentTextField;
@@ -29,12 +29,9 @@ @implementation ResetLabelViewController
29
29
- (void )viewDidLoad {
30
30
[super viewDidLoad ];
31
31
// Do any additional setup after loading the view.
32
- self.title = @" 重命名标签" ;
33
- self.navigationController .title = @" 重命名标签" ;
34
-
32
+ self.title = @" 编辑标签" ;
35
33
self.navigationItem .leftBarButtonItem = [UIBarButtonItem itemWithBtnTitle: @" 取消" target: self action: @selector (cancelBtnClick )];
36
34
self.navigationItem .rightBarButtonItem = [UIBarButtonItem itemWithBtnTitle: @" 完成" target: self action: @selector (okBtnClick )];
37
- self.navigationItem .rightBarButtonItem .enabled = FALSE ;
38
35
39
36
self.view .backgroundColor = kColorTableSectionBg ;
40
37
@@ -53,6 +50,12 @@ - (void)viewDidLoad {
53
50
});
54
51
}
55
52
53
+ - (void )viewWillAppear : (BOOL )animated {
54
+ [super viewWillAppear: animated];
55
+ _tempStr = _ptLabel.name ;
56
+ [_myTableView reloadData ];
57
+ }
58
+
56
59
- (void )didReceiveMemoryWarning {
57
60
[super didReceiveMemoryWarning ];
58
61
// Dispose of any resources that can be recreated.
@@ -100,8 +103,10 @@ - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(N
100
103
[tableView addLineforPlainCell: cell forRowAtIndexPath: indexPath withLeftSpace: kPaddingLeftWidth ];
101
104
cell.labelField .delegate = self;
102
105
[cell.labelField addTarget: self action: @selector (textFieldDidChange: ) forControlEvents: UIControlEventEditingChanged];
106
+ [cell.colorBtn addTarget: self action: @selector (colorBtnClick: ) forControlEvents: UIControlEventTouchUpInside];
103
107
cell.backgroundColor = kColorTableBG ;
104
108
cell.labelField .text = _ptLabel.name ;
109
+ cell.colorBtn .backgroundColor = [UIColor colorWithHexString: [_ptLabel.color stringByReplacingOccurrencesOfString: @" #" withString: @" 0x" ]];
105
110
return cell;
106
111
}
107
112
@@ -116,6 +121,13 @@ - (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSInde
116
121
return FALSE ;
117
122
}
118
123
124
+ #pragma mark - color
125
+ - (void )colorBtnClick : (UIButton *)sender {
126
+ EditColorViewController *vc = [EditColorViewController new ];
127
+ vc.curTag = _ptLabel;
128
+ [self .navigationController pushViewController: vc animated: YES ];
129
+ }
130
+
119
131
#pragma mark - UITextFieldDelegate
120
132
- (BOOL )textFieldShouldBeginEditing : (UITextField *)textField
121
133
{
@@ -134,12 +146,8 @@ - (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRang
134
146
135
147
- (void )textFieldDidChange : (UITextField *)textField
136
148
{
137
- _tempStr = textField.text ;
138
- if (_tempStr.length > 0 ) {
139
- self.navigationItem .rightBarButtonItem .enabled = [_tempStr isEqualToString: _ptLabel.name] ? FALSE : TRUE ;
140
- } else {
141
- self.navigationItem .rightBarButtonItem .enabled = FALSE ;
142
- }
149
+ self.tempStr = textField.text ;
150
+ self.navigationItem .rightBarButtonItem .enabled = _tempStr.length > 0 ;;
143
151
}
144
152
145
153
- (BOOL )textFieldShouldReturn : (UITextField *)textField
0 commit comments