| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent a9e4ed0 commit 88a055a
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,13 +11,13 @@ | |||
| 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 | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -11,6 +11,7 @@ | |||
| 11 | 11 | @interface ResetLabelCell : UITableViewCell | |
| 12 | 12 | ||
| 13 | 13 | @property (strong, nonatomic) UITextField *labelField; | |
| 14 | + @property (strong, nonatomic) UIButton *colorBtn; | ||
| 14 | 15 | ||
| 15 | 16 | + (CGFloat)cellHeight; | |
| 16 | 17 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -17,11 +17,19 @@ - (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reus | |||
| 17 | 17 | self.accessoryType = UITableViewCellAccessoryNone; | |
| 18 | 18 | self.backgroundColor = [UIColor clearColor]; | |
| 19 | 19 | // Initialization code | |
| 20 | + if (!_colorBtn) { | ||
| 21 | + _colorBtn = [[UIButton alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 7, 30, 30)]; | ||
| 22 | + _colorBtn.layer.masksToBounds = YES; | ||
| 23 | + _colorBtn.layer.cornerRadius = 4; | ||
| 24 | + [_colorBtn setImage:[UIImage imageNamed:@"tag_button_editColor"] forState:UIControlStateNormal]; | ||
| 25 | + [self.contentView addSubview:_colorBtn]; | ||
| 26 | + } | ||
| 20 | 27 | if (!_labelField) { | |
| 21 | - _labelField = [[UITextField alloc] initWithFrame:CGRectMake(kPaddingLeftWidth, 0, (kScreen_Width - kPaddingLeftWidth * 2), 44)]; | ||
| 28 | + _labelField = [[UITextField alloc] initWithFrame:CGRectMake(CGRectGetMaxX(_colorBtn.frame) + 10, 0, (kScreen_Width - kPaddingLeftWidth - CGRectGetMaxX(_colorBtn.frame) - 10), 44)]; | ||
| 22 | 29 | _labelField.textColor = [UIColor colorWithHexString:@"0x222222"]; | |
| 23 | 30 | _labelField.font = [UIFont systemFontOfSize:16]; | |
| 24 | 31 | _labelField.clearButtonMode = UITextFieldViewModeWhileEditing; | |
| 32 | + _labelField.placeholder = @"输入标签名称"; | ||
| 25 | 33 | [self.contentView addSubview:_labelField]; | |
| 26 | 34 | } | |
| 27 | 35 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments