Ios 滚动后UICollectionViewCell中的UILabel是否已设置?

Ios 滚动后UICollectionViewCell中的UILabel是否已设置?,ios,uicollectionview,uicollectionviewcell,Ios,Uicollectionview,Uicollectionviewcell,在我的代码中,我试图在UICollectionViewCell中使用UIImage和UIabel。如果UICollectionViewCell中没有图像,我要向上移动UILabel。因此我使用了两帧标签并检查了If(UIImageView.image==nil)滚动后是否显示效果? 怎么办? 这是我所做的代码- -(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForIt

在我的代码中,我试图在
UICollectionViewCell
中使用
UIImage
UIabel
。如果
UICollectionViewCell
中没有图像,我要向上移动
UILabel
。因此我使用了两帧标签并检查了
If(UIImageView.image==nil)
滚动后是否显示效果? 怎么办? 这是我所做的代码-

-(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;

 }

}

尝试在每个collectionView中删除单元格contentView子视图

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

方法调用

使用

并替换这行代码 UICollectionViewCell myCell=(UICollectionViewCell)[self.view viewWithTag:1]


UICollectionViewCell*myCell=nil

在此之后,将子视图添加到TABLECELL的内容视图中
for([UIView  *view in cell.contentView.subViews]){
    [view removeFromSuperView];
    view=nil;
}