5

テーブル ビューがあり、奇数セルの高さをすべて 0 に設定しました。奇数セルにはいくつかのラベルがありました。テーブルビューを表示すると、奇数セルのラベルが偶数セルに表示されます。ラベルを消す方法はありますか?この問題は ios 6 p/s で発生しました: ios 7 で: 正しく動作します。私はすでにメソッドを持っていました: [tableView beginUpdates]; [tableView endUpdates];

ありがとう。

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{

    // show odd row
    if (selectedRow == indexPath.row) return 78;

    // hide odd row  and show even row
    if (indexPath.row %2 ==0){
        return 88;}
    else{
        return 0;}
}

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


    if (indexPath.row%2 == 0){


        //user click on even row -> display the next row 
        selectedRow = indexPath.row+1;

        [tableView beginUpdates];

        [tableView endUpdates];

    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    int index = indexPath.row / 2;

    if (indexPath.row %2 ==0){

        static NSString *CellIdentifier = @"PhraseViewCell";

        PhraseCellVietnamese *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

        NSString *phrase = [[phrases objectAtIndex:index] objectForKey:@"vietnamese"];

        NSNumber *checkFavorite =  [[phrases objectAtIndex:index] objectForKey:@"favorite"];

        NSNumber *phraseId =[[phrases objectAtIndex:index] objectForKey:@"_id"];

        [cell SetInfo:phrase :checkFavorite.intValue :phraseId.intValue];

        return cell;

    }
    else{

        static NSString *CellIdentifier = @"PinyinViewCell";

        PinYinViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

        NSString *pinyin = [[phrases objectAtIndex:index] objectForKey:@"pinyin"];

        NSString *chinese = [[phrases objectAtIndex:index] objectForKey:@"chinese"];

        NSString *voice = [[phrases objectAtIndex:index] objectForKey:@"voice"];

        [cell setInfo:pinyin :chinese :voice];

        return cell;
    }
}
4

2 に答える 2

25

[セル setClipsToBounds:YES]; cellForRowAtIndexPath で

私のために働いた。解決策を見つけてください。

于 2013-12-17T19:41:40.400 に答える