【发布时间】:2014-02-10 10:26:10
【问题描述】:
我创建 UITableView 并将文本字段添加到单元格的内容以允许用户输入他的数据,当用户结束编辑文本字段时,我想将插入数据保存在文本字段中,但问题是 UITextField检索空值。
在cellForRowAtIndexPath我添加了
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
}
TextField1 = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 80,45)];
TextField2 = [[UITextField alloc] initWithFrame:CGRectMake(83, 0, 70,45)];
TextField3 = [[UITextField alloc] initWithFrame:CGRectMake(156, 0, 70,45)];
[TextField1 setDelegate:self];
[TextField2 setDelegate:self];
[TextField3 setDelegate:self];
TextField1.userInteractionEnabled=YES;
TextField1.enabled=YES;
TextField2.userInteractionEnabled=YES;
TextField2.enabled=YES;
TextField3.userInteractionEnabled=YES;
TextField3.enabled=YES;
[cell.contentView addSubview:TextField1];
[cell.contentView addSubview:TextField2];
[cell.contentView addSubview:TextField3];
return cell;
}
- (void)textFieldDidEndEditing:(UITextField *)textField{
NSString*VisitDateStr=[NSString stringWithFormat:@"%@",TextField1.text];
NSLog(@"%@",VisitDateStr);
}
结果(空)。 如何检索在 tableview 的文本字段中插入的用户详细信息?
谢谢,感谢您的帮助。
【问题讨论】:
标签: objective-c uitableview uitextfield