0

セルをタップしてセルを拡大しています。古いラベルを非表示にしたいので、新しいラベルを追加する必要があります。

セルの内容を非表示にすると、すべての再利用可能なセルの内容が非表示になります。(セル 1 の選択と同様に、古いラベルを非表示にしてセル 1 の新しいラベルを表示したいのですが、1、6、11 .. 行のラベルを非表示にします)

私は解決策を見つけることができません。

私はこのコードを使用しています

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{    

        BOOL isSelected = ![self cellIsSelected:indexPath];

        // Store cell 'selected' state keyed on indexPath
        NSNumber *selectedIndex = [NSNumber numberWithBool:isSelected];
        [selectedIndexes setObject:selectedIndex forKey:indexPath];        

        [self.newsTableview beginUpdates];

        UITableViewCell *tableviewCell = [tableView cellForRowAtIndexPath:indexPath];
        UITextView *textView = (UITextView *)[tableviewCell.contentView viewWithTag:101];
        UILabel *label = (UILabel *)[tableviewCell.contentView viewWithTag:100];
        UIImageView *imageView1 = (UIImageView *)[tableviewCell.contentView viewWithTag:102];

         if([self cellIsSelected:indexPath])
         {          
             label.hidden = YES;
             imageView1.hidden = YES;
             textView.hidden = YES;           
         }        

        [self.newsTableview endUpdates];                       


    // Deselect cell
    [tableView deselectRowAtIndexPath:indexPath animated:TRUE];
}

助けてください..よろしくお願いします

4

3 に答える 3

1

怒鳴るようdequeueReusableCellWithIdentifierに使用nil

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil];

または、次のような別の識別子を割り当てます...

   NSString *CellIdentifier =[NSString stringWithFormat:@"%d%d",indexPath.section,indexPath.row];
 UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
于 2012-12-13T08:06:17.330 に答える
0
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];

このようにCell Identifierを1つだけ使用していると思います。何かを変更すると、それらすべてに影響します。別の識別子を使用してみてください。

于 2012-12-13T09:56:55.037 に答える