私は、私のスクロール時にUITableViewの私の行に適用されるというチェックマークがすべて混在する問題があります。私はかなり確かにこれは、iphoneがどのように細胞を再利用しているのかと関係しています。私が離れたところからスクロールするとチェックマークが付いています。Iphone:スクロール時にUITableviewのチェックマークが混乱する
誰かが私にこれを避ける方法や、おそらく私の方法を見て、何かが見えるかどうかについてのヒントを教えてください。
ユーザーが作成した各行の選択を保存してから、どの行が表示されているかを確認して、正しい行にチェックマークが付いているかどうかを確認することもできますが、そうする方法はありません。
ありがとうございます。あなたはセルが状態をデフォルトと行の状態をチェックし、状態を変更するためにそれをリセット取得した後
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
CustomCell *cell = (CustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[CustomCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
[cell setAccessoryView:nil];
}
NSMutableArray *temp = [[NSMutableArray alloc]init];
for (int j = 0; j < [listOfRowersAtPractice count]; j++) {
if ([[differentTeams objectAtIndex:indexPath.section] isEqualToString:[[rowersAndInfo objectForKey:[listOfRowersAtPractice objectAtIndex:j]]objectForKey:@"Team"]]) {
[temp addObject:[listOfRowersAtPractice objectAtIndex:j]];
}
}
[cell.cellText setText:[temp objectAtIndex:indexPath.row]];
[temp removeAllObjects];
[temp release];
// Set up the cell...
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tableView deselectRowAtIndexPath:indexPath animated:YES];
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
if (cell.accessoryType != UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
}
これは、配列が選択されている場合にその配列をどのように配置するかを記述できますが、配列内に既に存在する場合は削除してもかまいませんか? –
私の編集を今すぐチェック –