如何检查UICollectionView是否有图像


岁爵
2024-12-29 04:31:55 (2月前)
  1. 我有4UICollectionViewCell,其中我想要制作前2个单元格以使其中的图像成为必需的。示例代码如下。下面是一个用例:

如果我点击每个单元格,有4个UICollectionViewCell …

2 条回复
  1. 0# Just do it | 2019-08-31 10-32



    您可以检查是否有图像

    UIImageView

    或不这样:




    1. -(BOOL) checkImages {
      for (int i=0, i<2 , i++) {
      NSIndexPath indexPath = [NSIndexPath indexPathForItem:i inSection:0];
      ADRPhotoCollectionViewCell
      cell = [collectionView cellForItemAtIndexPath:indexPath];
      if (cell.imageView.image == nil || CGSizeEqualToSize(cell.imageView.image.size, CGSizeZero)) {
      //there isn’t any image or the image is empty
      return NO;
      }
      }
      return YES;
      }

    2. </code>

登录 后才能参与评论