Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
165 lines (137 loc) · 5.05 KB

File metadata and controls

165 lines (137 loc) · 5.05 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
//
// ResetLabelViewController.m
// Coding_iOS
//
// Created by zwm on 15/4/17.
// Copyright (c) 2015年 Coding. All rights reserved.
//
#import "ResetLabelViewController.h"
#import "ResetLabelCell.h"
#import "TPKeyboardAvoidingTableView.h"
#import "Coding_NetAPIManager.h"
#import "ProjectTag.h"
#import "EditColorViewController.h"
#define kCellIdentifier_ResetLabelCell @"ResetLabelCell"
@interface ResetLabelViewController () <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>
@property (strong, nonatomic) NSString *tempStr;
@property (strong, nonatomic) TPKeyboardAvoidingTableView *myTableView;
@property (nonatomic, weak) UITextField *mCurrentTextField;
@end
@implementation ResetLabelViewController
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.title = @"编辑标签";
self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithBtnTitle:@"取消" target:self action:@selector(cancelBtnClick)];
self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithBtnTitle:@"完成" target:self action:@selector(okBtnClick)];
self.view.backgroundColor = kColorTableSectionBg;
_myTableView = ({
TPKeyboardAvoidingTableView *tableView = [[TPKeyboardAvoidingTableView alloc] initWithFrame:self.view.bounds style:UITableViewStyleGrouped];
tableView.backgroundColor = kColorTableSectionBg;
tableView.delegate = self;
tableView.dataSource = self;
[tableView registerClass:[ResetLabelCell class] forCellReuseIdentifier:kCellIdentifier_ResetLabelCell];
tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
[self.view addSubview:tableView];
[tableView mas_makeConstraints:^(MASConstraintMaker *make) {
make.edges.equalTo(self.view);
}];
tableView;
});
_tempStr = _ptLabel.name;
}
- (void)viewWillAppear:(BOOL)animated{
[super viewWillAppear:animated];
[_myTableView reloadData];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (void)dealloc
{
_myTableView.delegate = nil;
_myTableView.dataSource = nil;
}
#pragma mark - click
- (void)cancelBtnClick
{
[self.navigationController popViewControllerAnimated:YES];
}
- (void)okBtnClick
{
if (_tempStr.length > 0) {
__weak typeof(self) weakSelf = self;
_ptLabel.name = _tempStr;
[[Coding_NetAPIManager sharedManager] request_ModifyTag:_ptLabel inProject:_curProject andBlock:^(id data, NSError *error) {
if (data) {
[weakSelf.navigationController popViewControllerAnimated:YES];
}
}];
}
}
#pragma mark - UITableViewDataSource
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
ResetLabelCell *cell = [tableView dequeueReusableCellWithIdentifier:kCellIdentifier_ResetLabelCell forIndexPath:indexPath];
[tableView addLineforPlainCell:cell forRowAtIndexPath:indexPath withLeftSpace:kPaddingLeftWidth];
cell.labelField.delegate = self;
[cell.labelField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
[cell.colorBtn addTarget:self action:@selector(colorBtnClick:) forControlEvents:UIControlEventTouchUpInside];
cell.backgroundColor = kColorTableBG;
cell.labelField.text = _tempStr;
cell.colorBtn.backgroundColor = [UIColor colorWithHexString:[_ptLabel.color stringByReplacingOccurrencesOfString:@"#" withString:@"0x"]];
return cell;
}
#pragma mark - UITableViewDelegate
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return [ResetLabelCell cellHeight];
}
- (BOOL)tableView:(UITableView *)tableView shouldHighlightRowAtIndexPath:(NSIndexPath *)indexPath
{
return FALSE;
}
#pragma mark - color
- (void)colorBtnClick:(UIButton *)sender{
EditColorViewController *vc = [EditColorViewController new];
vc.curTag = _ptLabel;
[self.navigationController pushViewController:vc animated:YES];
}
#pragma mark - UITextFieldDelegate
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
{
self.mCurrentTextField = textField;
return YES;
}
- (void)textFieldDidEndEditing:(UITextField *)textField
{
}
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string
{
return YES;
}
- (void)textFieldDidChange:(UITextField *)textField
{
self.tempStr = textField.text;
self.navigationItem.rightBarButtonItem.enabled = _tempStr.length > 0;;
}
- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
[textField resignFirstResponder];
return YES;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
[super touchesBegan:touches withEvent:event];
[self.mCurrentTextField resignFirstResponder];
}
@end
Morty Proxy This is a proxified and sanitized view of the page, visit original site.