【发布时间】:2013-04-01 10:46:19
【问题描述】:
我有一个UITableView 和一堆UITableViewCells。这些UITableViewCells 内部有多个UITextFields。
现在,每次我上下滚动,UITableViewCells 退出视图,然后返回,我在 UITextField 中输入的任何文本都会消失。完成这项工作的最佳方法是什么?
static NSString *CellIdentifier = @"Cell";
ComplaintsCustomCell *cell=(ComplaintsCustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if(cell==nil){
NSArray *topLevelObjects = [[NSBundle mainBundle] loadNibNamed:@"ComplaintsCustomCell" owner:self options:nil];
for(id currentObject in topLevelObjects){
if([currentObject isKindOfClass:[UITableViewCell class]]){
cell = (ComplaintsCustomCell *) currentObject;
break;
}
}
}
cell.durationFld.text=[dict valueForKey:@"Duration"];
[cell.durationFld setTag:indexPath.row + 5000];
【问题讨论】:
-
放置cellForRowAtindexpath的代码
-
我认为你已经在 if (cell == nil) 条件之外编写了文本字段分配代码
-
检查一下您的 cellIdentifier。
-
你能在这里发布 cellForRowAtIndexPath 代码吗?我认为重用问题
-
你从哪里得到那个版本的 loadNibNamed?这似乎不是 Apple 标准问题。
标签: ios objective-c uitableview uitextfield