0

ランダムに発生する奇妙な問題があります。スクロールしてセルに戻ると、セルは塗りつぶされていない状態になります。何が起こっているかについては、以下の画像を参照してください。これが私のテーブルビューのデリゲートです。

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    NSLog(@"%lu",(unsigned long)[datas count]);
    return [datas count];
}

- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    //NSLog(@"%@",[sects objectAtIndex:section]);
    return [self cleanText:[sects objectAtIndex:section]];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    //return [datas count];
    //NSLog(@"%ld",(long)[[datas objectAtIndex:section] count]);
    return (NSInteger)[[datas objectAtIndex:section] count];
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"MyCell";
    HHCellPlaceOrder *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];

    //NSLog(@"Method Called");

    //Get NSDictionary for Cell
    NSDictionary *dict = [[datas objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];

    cell.lblSku.text = [dict objectForKey:@"itemnumber"];
    cell.lblDescription.text = [dict objectForKey:@"description"];

    cell.lblSize.text = [dict objectForKey:@"itemsize"];
    cell.lblUnitCost.text = [dict objectForKey:@"netcost"];
    cell.lblQtyOnHand.text = [dict objectForKey:@"inventory"];

    cell.lblCost.text = [dict objectForKey:@"costfield"];

    cell.txtQty.text = [dict objectForKey:@"qtyfield"];

    if ([cell.txtQty.text isEqualToString:@"0"] == NO) {
        cell.cellBG.backgroundColor = [UIColor lightGrayColor];
        //cell.lblUPC.backgroundColor = [UIColor lightGrayColor];
    } else{
        cell.cellBG.backgroundColor = [UIColor whiteColor];
        //cell.lblUPC.backgroundColor = [UIColor whiteColor];
    }

    CGRect frame = cell.cellBG.frame;
    if ([[dict objectForKey:@"showBar"] isEqualToString:@"1"]){
        cell.img_bar.hidden = NO;
        cell.lblUPC.hidden = NO;
        cell.lblUPC.backgroundColor = [UIColor whiteColor];
        //Bar Code...
        NKDUPCABarcode *bar = [NKDUPCABarcode alloc];
        bar = [bar initWithContent:[dict objectForKey:@"UPC"]];
        UIImage *i = [UIImage imageFromBarcode:bar];
        cell.img_bar.image = i;
        cell.img_bar.backgroundColor = [UIColor whiteColor];
        cell.lblUPC.text = [dict objectForKey:@"UPC"];

        frame.size.height = 158;
    } else{
        cell.img_bar.hidden = YES;
        cell.lblUPC.hidden = YES;

        cell.img_bar.image = nil;
        cell.lblUPC.text = @"";

        frame.size.height = 55;
    }
    cell.cellBG.frame = frame;

    return cell;
}
-(NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    return nil;
}

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSDictionary *dict = [[datas objectAtIndex:indexPath.section] objectAtIndex:indexPath.row];

    if ([[dict objectForKey:@"showBar"] isEqualToString:@"1"]){
        return 158.0f;
    } else{
        return 55.0f;
    }
}

画像 - まだ画像を投稿できないのでリンク:(

通常表示 - https://dl.dropboxusercontent.com/u/14627145/normallook.jpg

いくつかのスクロール例の後 - https://dl.dropboxusercontent.com/u/14627145/WeirdCell1.jpg

私が得ることができるどんな助けにも感謝します!:D

4

0 に答える 0