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]);}