2014-03-24 60 views
-1

在我的代碼,我試圖用UIImage & UIabelUICollectionViewCell。什麼我做如果在UICollectionViewCell沒有像我想轉移UILabel upwards.So我用標籤的兩幀,並檢查if(UIImageView.image==nil)它顯示效果滾動後? 怎麼辦? 這裏是我did-UILabel UICollectionViewCell在滾動後設置?

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

UICollectionViewCell *myCell=(UICollectionViewCell*)[self.view viewWithTag:1]; 
myCell = [collectionView 
          dequeueReusableCellWithReuseIdentifier:@"Cell" 
          forIndexPath:indexPath]; 

UILabel *label=(UILabel*)[myCell viewWithTag:12]; 

UIImageView *collectionViewImage=(UIImageView*)[myCell viewWithTag:11]; 



NSString *collectionViewImageName=[imagesCollectionViewArray objectAtIndex:indexPath.row]; 
collectionViewImage.image=[UIImage imageNamed:collectionViewImageName]; 


if (collectionViewImage.image==nil) { 

[collectionViewImage setBackgroundColor:[UIColor clearColor]]; 
[label setFrame:CGRectMake(35, 73, 309, 54)]; 
label.text=[lableColectionviewArray objectAtIndex:indexPath.row]; 
return myCell; 
}else { 

[label setFrame:CGRectMake(20, 294, 352, 49)]; 
label.text=[lableColectionviewArray objectAtIndex:indexPath.row]; 
return myCell; 

} 

} 

回答

0

嘗試刪除單元格內容查看每個子視圖的CollectionView

代碼 - (UICollectionViewCell *)的CollectionView:(UICollectionView *)的CollectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath

方法調用。

使用

for([UIView *view in cell.contentView.subViews]){ 
    [view removeFromSuperView]; 
    view=nil; 
} 

和替換這行代碼 UICollectionViewCell 了myCell =(UICollectionViewCell)[self.view viewWithTag:1];

With

UICollectionViewCell * myCell = nil;

+0

其刪除所有的意見...並使我的手機零... – user3422834

+0

此後添加子菜單的內容視圖的TABLECELL –

相關問題