【发布时间】:2011-04-13 11:09:49
【问题描述】:
我有一个分段的 tableView,它加载所有部分的所有单元格中的所有数据。 每个单元格中都有一个 textField。
tableview 不完全适合 iPad 屏幕,我无法访问所有不可见的单元格以读取/保存数据。当我在“textField”中进行更改时,向上滚动,向下滚动,所有更改都消失了。
我需要加载所有单元格,甚至一次不可见,才能访问它们。
对不起,我几天前才开始使用表格... 我认为这个问题与可重复使用的细胞有关,但不知道如何解决。
请寻求您的帮助。
初始化:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 400, 30)] ;
textField.enabled = NO;
cell.accessoryView = textField;
[textField release];
}
UITextField *textField = (UITextField*)cell.accessoryView;
if(indexPath.section == 0)
cell.textLabel.text = [idenInfo objectAtIndex:indexPath.row];
else if (indexPath.section == 1)
cell.textLabel.text = [prodInfo objectAtIndex:indexPath.row];
else if (indexPath.section == 2)
cell.textLabel.text = [visInfo objectAtIndex:indexPath.row];
if(indexPath.section == 0)
textField.text = [idenInfoRez objectAtIndex:indexPath.row];
else if (indexPath.section == 1)
textField.text = [prodInfoRez objectAtIndex:indexPath.row];
else if (indexPath.section == 2)
textField.text = [visInfoRez objectAtIndex:indexPath.row];
textField = nil;
return cell;
}
【问题讨论】:
标签: iphone objective-c ios ipad uitableview