iOS   发布时间:2022-03-31  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – 在customCell中循环浏览uiimageview大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
你好,我有产品表和产品详细信息视图为每个产品我有很多图像,下载和缓存在磁盘和内存,每次用户选择一个产品,以检查其细节我正在检索缓存的图像,并设置为我的四UI ImageView在UITableViewController中的自定义单元格内,我无法设置图像,尽管我可以通过NSLog()函数记录它我正在使用此代码
int index = 0;
    int indexOfImages = 1;
    self.imageCache = [[SDImageCache alloc] initWithNamespace:@"menuImage"];
   for ( UIImageView *currentImageView in cell.contentView.subviews)
    {
        NSLog(@"the imageindex is: %d",indexOfImages);
        NSLog(@"the index is: %d",indeX);
        NSLog(@"the count is: %lu",(unsigned long)[self.currentProduct.mirsaProductUrlImage count]);
        if (index < [self.currentProduct.mirsaProductUrlImage count] ) {
             [self.imageCache queryDiskCacheForKey:self.currentProduct.mirsaProductUrlImage[indexOfImages]  
    done:^(UIImage *image,SDImageCacheType cacheTypE) {
                if (imagE) {
                   currentImageView.image =  image;
                }
            }];
            indexOfImages++;
            index++;
         }
         else
        {
            break;
        }
    }
for ( UIImageView *currentImageView in self.tableView.subViews)

我只是想知道我是否以错误的方式循环,我的意思是我无法通过这个循环达到他们或发生了什么?

解决方法

你必须改变循环:
for ( UIView *currentView in cell.contentView.subviews)
   {
      if([currentView isKindOfClass:[UIImageView class]])
      {
           // here Do All the stuff for imageViews
      }
   }

所有这些东西在cellForRowATindexPath
并改变imageView图像采取的弱视频imageView这样的例子:

__weak UIImageView *weakImage = currentImageView;
 [self.imageCache queryDiskCacheForKey:self.currentProduct.mirsaProductUrlImage[indexOfImages]  
    done:^(UIImage *image,SDImageCacheType cacheTypE) {
                if (imagE) {
                    weakImage.image =  image;
                }
 }];

大佬总结

以上是大佬教程为你收集整理的ios – 在customCell中循环浏览uiimageview全部内容,希望文章能够帮你解决ios – 在customCell中循环浏览uiimageview所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。