【发布时间】:2012-01-17 09:41:27
【问题描述】:
我使用表格来编辑模型对象(注释实例)的属性。表格中的单元格对应Annotation类的不同属性:
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellAnnotation"];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"cellAnnotation"] autorelease];
}
[[cell textLabel] setText:@"Category"];
categoryField = [[UITextField alloc] initWithFrame:CGRectMake(90, 8, 200, 25)];
[categoryField setAutocorrectionType:UITextAutocorrectionTypeNo];
[categoryField setFont:[UIFont fontWithName:@"Verdana" size:15]];
[categoryField setText:[[annotation category] name]];
[categoryField setDelegate:self];
[[cell contentView] addSubview:categoryField];
[categoryField release];
return cell;
令人惊讶的是,如果我在控制器的 viewWillAppear 方法中重新加载数据,那么我会得到一个奇怪的行为:按下退格键时 UITextField 中的字符不会被清除,尽管在退出第一响应者时它们不存在在 UITextField 中并检索其文本属性。谁能帮我?提前致谢。
【问题讨论】:
标签: ios uitableview uitextfield