2016-03-21 103 views
0

我有收集视图里面,我正在加载图像(图像有长按手势识别器)。 集合视图单元格未完全加载时,didSelectItemAtIndexPath方法未被调用。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; 

} 

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

+0

显示您的代码。 – Fogmeister

+0

单元格中是否有任何按钮? – sourav

+0

@sourav单元格内没有按钮 – vijeesh

回答

0

didSelectItemAtIndexPathUICollectioView的委托方法,请确保您绑定了UICollectionViewDatasourceDelegate正确。

+0

我已添加数据源n委托didSelectItemAtIndexPath正在其他情况下工作.... – vijeesh

+0

请分享代码。 –

+0

我添加了问题 – vijeesh