当前位置: 代码迷 >> Iphone >> 怎样获得TableView中TextField.text?解决思路
  详细解决方案

怎样获得TableView中TextField.text?解决思路

热度:125   发布时间:2016-04-25 06:45:01.0
怎样获得TableView中TextField.text?
tableView的cell中有TextField,怎样在导航离开此view或编辑完TextField时,获得TextField.text的值?

------解决方案--------------------
UITableViewCell* cell = [self.utvLeft cellForRowAtIndexPath:indexPath];
if (cell != nil) 
{
TextField *field = (TextField*)[cell viewWithTag:CELL_TEXTFIELD];

------解决方案--------------------
吃饭去。写全部给你看看
C/C++ code
         UITextField *textField=[[UITextField alloc] initWithFrame:CGRectMake(250, 50, 150, 22)];        textField.tag=[indexPath row];        textField.delegate=self;        textField.placeholder = @"请输入";        textField.font = [UIFont fontWithName:@"Times New Roman" size:25];        [textField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];        [cell addSubview:textField];//第二步,实现回调函数- (void) textFieldDidChange:(id) sender {    NSNumber *tag=[NSNumber numberWithInt:[sender tag]];    UITextField *_field = (UITextField *)sender;    NSLog(@"tag%@",tag);    NSLog(@"_field%@",[_field text]);}
  相关解决方案