GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Coding-iOS/Coding_iOS/Controllers/ResetLabelViewController.m at master · TDness/Coding-iOS Expand file tree/ Copy pathResetLabelViewController.mMore file actions 157 lines (131 loc) · 4.66 KB / Copy pathResetLabelViewController.mFile metadata and controls157 lines (131 loc) · 4.66 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 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 // // 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" #define kCellIdentifier_ResetLabelCell @"ResetLabelCell" @interface ResetLabelViewController () <UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate> { 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.navigationController.title = @"重命名标签"; self.navigationItem.leftBarButtonItem = [UIBarButtonItem itemWithBtnTitle:@"取消" target:self action:@selector(cancelBtnClick)]; self.navigationItem.rightBarButtonItem = [UIBarButtonItem itemWithBtnTitle:@"完成" target:self action:@selector(okBtnClick)]; self.navigationItem.rightBarButtonItem.enabled = FALSE; 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; }); } - (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.backgroundColor = kColorTableBG; cell.labelField.text = _ptLabel.name; 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 - 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 { _tempStr = textField.text; if (_tempStr.length > 0) { self.navigationItem.rightBarButtonItem.enabled = [_tempStr isEqualToString:_ptLabel.name] ? FALSE : TRUE; } else { self.navigationItem.rightBarButtonItem.enabled = FALSE; } } - (BOOL)textFieldShouldReturn:(UITextField *)textField { [textField resignFirstResponder]; return YES; } - (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event { [super touchesBegan:touches withEvent:event]; [self.mCurrentTextField resignFirstResponder]; } @end |
| You are visitor 01402520 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |