未完全加载单元格时,不会调用didSelectItemAtIndexPath

时间:2016-03-21 14:00:30

标签: ios objective-c uitableview

我有内部的集合视图,我正在加载图像(图像有长按手势识别器)。 当未完全加载集合视图单元格时,不会调用didSelectItemAtIndexPath方法。

我向下滚动并加载所有内容然后我将该单元格置于一个位置(附加屏幕截图)现在,didSelectItemAtIndexPath方法被称为In this position the didSelectItemAtIndexPath is not getting called

下面的cellForItemAtIndexPath代码: -

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath
{

    modelProductDetails=[self.productsArray objectAtIndex:indexPath.row];

    PLPCollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"plpcollectiocellIdentifier" forIndexPath:indexPath];
    [cell.imgview addGestureRecognizer:longPress];



    cell.conlblofferpriceheight.constant=21;
    cell.shareView.alpha = 0;

    double actualPrice = [modelProductDetails.price doubleValue];// striked out
    double offerPrice = [modelProductDetails.final_price doubleValue];//will be in red instead of special price

    cell.lblitemPrice.text = [MyShoppingCartViewController displayFormattedPrice: modelProductDetails.price];


    if (offerPrice < actualPrice && offerPrice != 0) {

        NSMutableAttributedString *priceString = [[NSMutableAttributedString alloc] initWithString:[NSString stringWithFormat:@"%@" ,cell.lblitemPrice.text]];

        [priceString addAttribute:NSStrikethroughStyleAttributeName value:[NSNumber numberWithInteger:NSUnderlineStyleSingle] range:NSMakeRange(0, [priceString length])];

        cell.lblitemofferprice.text = [MyShoppingCartViewController displayFormattedPrice:modelProductDetails.final_price];

        [cell.lblitemPrice  setAttributedText:  priceString];

    }
    else
    {
        [cell.lblitemofferprice setText:nil];
    }


    cell.lblIteeTitle.text=modelProductDetails.brand;
    cell.lblitemDescription.text=modelProductDetails.name;
    cell.lblIteeTitle.text=modelProductDetails.manufacturer_value;

    NSURL *url=[NSURL URLWithString:modelProductDetails.small_image];
    [cell.imgview sd_setImageWithURL:url placeholderImage:nil];


    UILongPressGestureRecognizer *longPressGes = [[UILongPressGestureRecognizer alloc] initWithTarget:self action:@selector(handleLongPressGestures:)];
    longPressGes.minimumPressDuration = 1.0f;
    longPressGes.allowableMovement = 100.0f;
    [cell.imgview addGestureRecognizer:longPressGes];
    [cell.shareButton setTag:indexPath.row];
    [cell.addToWishlistButton setTag:indexPath.row];
    [cell.shareButton addTarget:self action:@selector(shareAction:) forControlEvents:UIControlEventTouchUpInside];
    [cell.addToWishlistButton addTarget:self action:@selector(addToWishlistAction:) forControlEvents:UIControlEventTouchUpInside];
    cell.shareButton.tag=indexPath.row;
    cell.addToWishlistButton.tag=indexPath.row;

    return cell;

}

附加信息:只有右侧的单元格左侧的单元格工作正常

1 个答案:

答案 0 :(得分:0)

didSelectItemAtIndexPathUICollectioView的委托方法,请确保正确绑定UICollectionView DatasourceDelegate