2013-10-29 36 views
2

我在我的應用程序中使用UICollectionview時,我重新加載它在ios 7中的uicollectionviewcell中的子視圖,但在ios 6中它工作正常,任何人都知道可能是什麼原因以及如何解決這個問題。UIollectionView重新加載ios 7中的Ovelaps

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath]; 
    dispatch_async(dispatch_get_main_queue(), ^{ 
      if ([self.collectionviewFlow.indexPathsForVisibleItems containsObject:indexPath]) { 
       NSString *img_name=[NSString stringWithFormat:@"%@_thumb%d.png",self.VaritiesName,(int)indexPath.row+1]; 
       imageVw=[[UIImageView alloc]initWithImage:[UIImage imageNamed: img_name]]; 
       imageVw.frame=CGRectMake(10,10,100,100); 
       [cell.contentView addSubview:imageVw]; 
      } 
     }); 
    cell.backgroundColor=[UIColor clearColor]; 
    return cell; 
} 
+0

發佈您的一些代碼。 – user1673099

+0

我已附上密碼 – Raja

回答

2

試試這個辦法...... & 讓我知道

- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UICollectionViewCell *cell=[collectionView dequeueReusableCellWithReuseIdentifier:@"cellIdentifier" forIndexPath:indexPath]; 
    dispatch_async(dispatch_get_main_queue(), ^{ 

     // ********* Changed ******* 

     for (UIView *v in [cell.contentView subviews]) 
     [v removeFromSuperview]; 

    // ********** Changed ********** 
      if ([self.collectionviewFlow.indexPathsForVisibleItems containsObject:indexPath]) { 
       NSString *img_name=[NSString stringWithFormat:@"%@_thumb%d.png",self.VaritiesName,(int)indexPath.row+1]; 
       imageVw=[[UIImageView alloc]initWithImage:[UIImage imageNamed: img_name]]; 
       imageVw.frame=CGRectMake(10,10,100,100); 
       [cell.contentView addSubview:imageVw]; 
      } 
     }); 
    cell.backgroundColor=[UIColor clearColor]; 
    return cell; 
} 
+0

這對您有幫助嗎? – user1673099

+0

雅精細作品。感謝Dude ... – Raja

+0

@Raja,非常感謝接受答案...快樂編碼! +1爲你... – user1673099