国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

UITableView延伸:點擊cell關閉鍵盤,加載不同cell,監聽里面的textfeild內容改變

2019-11-14 18:06:37
字體:
來源:轉載
供稿:網友

其實點擊cell關閉鍵盤只要一句話

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [tableView endEditing:YES];
}

 監聽里面的textfeild內容改變其實就是當textfeild內容改變的時候將賦值給他的數組的數據改變下就行了,用tag標示不同的textfeild

        newcell.textfeild.delegate = self;
        newcell.textfeild.tag = indexPath.row;
        newcell.textfeild.text = self.arrayWithCell3[indexPath.row];

 在UITextFieldDelegate代理方法中通過tag改變相應的數據

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    self.arrayWithCell3[textField.tag] = [textField.text mutableCopy];
    return YES;
}

 加載不同的cell就是給他注冊不同的cell,取的時候也那樣取就行了

注冊:

    [_tableveiw registerClass:[CustomCell class] forCellReuseIdentifier:@"cellID"];
    [_tableveiw registerClass:[CustomCell1 class] forCellReuseIdentifier:@"cellID1"];
    [_tableveiw registerClass:[CustomCell2 class] forCellReuseIdentifier:@"cellID2"];

 加載:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = nil;
    if (indexPath.section == 0) {
        cell = [tableView dequeueReusableCellWithIdentifier:@"cellID"];
        CustomCell *newcell = (CustomCell *)cell;
        newcell.label.text = @"00000";
        
    }else if (indexPath.section == 1){
        cell = [tableView dequeueReusableCellWithIdentifier:@"cellID1"];
    }else {
        cell = [tableView dequeueReusableCellWithIdentifier:@"cellID2"];
        CustomCell2 *newcell = (CustomCell2 *)cell;
        newcell.textfeild.delegate = self;
        newcell.textfeild.tag = indexPath.row;
        newcell.textfeild.text = self.arrayWithCell3[indexPath.row];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

 demo鏈接:https://github.com/WuJiForFantasy/UITableViewCell.git

 

 

 


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新安县| 汝州市| 宁强县| 茂名市| 垣曲县| 沂水县| 保康县| 台山市| 毕节市| 芦溪县| 察隅县| 广州市| 利辛县| 祥云县| 景德镇市| 金塔县| 郴州市| 阿巴嘎旗| 隆林| 东明县| 阿坝县| 桃江县| 余干县| 胶州市| 祁阳县| 桂平市| 沈丘县| 育儿| 农安县| 芒康县| 体育| 綦江县| 桑植县| 浦县| 阿图什市| 阜平县| 渭源县| 阿克苏市| 诏安县| 安陆市| 龙井市|