Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/110.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 将imageCache中的图像设置为imageCache的开头,而不是结尾_Ios_Swift_Uitableview_Object_Caching - Fatal编程技术网

Ios 将imageCache中的图像设置为imageCache的开头,而不是结尾

Ios 将imageCache中的图像设置为imageCache的开头,而不是结尾,ios,swift,uitableview,object,caching,Ios,Swift,Uitableview,Object,Caching,我使用以下命令将对象设置到imageCache: self.picPostPicImageCache.setObject(UIImage(data:imageData)!,forKey: urlString as NSString) } 这在tableview中使用,如下所示: let cell : ImagePostTableViewCell = BarSelectedTableView.dequeueReusableCel

我使用以下命令将对象设置到imageCache:

    self.picPostPicImageCache.setObject(UIImage(data:imageData)!,forKey: urlString as NSString)
                          }
这在tableview中使用,如下所示:

    let cell : ImagePostTableViewCell = BarSelectedTableView.dequeueReusableCell(withIdentifier: "ImagePostTableViewCell", for: indexPath) as! ImagePostTableViewCell
        if let PicPostCacheImage = picPostPicImageCache.object(forKey: picPostPicUrlArray[indexPath.row] as NSString) { if let PicProPicCacheImage = picPostProPicImageCache.object(forKey: picPostProPicUrlArray[indexPath.row] as NSString) {

            cell.userImagePostView.image = PicPostCacheImage
            cell.userImageView.image = PicProPicCacheImage
            }
        } else {
            cell.userImagePostView.sd_setImage(with: URL(string: picPostPicUrlArray[indexPath.row] as String), placeholderImage: UIImage(named: "defaultPropic"), options: [.continueInBackground, .progressiveLoad])
            cell.userImageView.sd_setImage(with: URL(string: picPostProPicUrlArray[indexPath.row] as String), placeholderImage: UIImage(named: "defaultPropic"), options: [.continueInBackground, .progressiveLoad])

        }
我遇到的问题是当我想向缓存中添加新照片时。目前,我使用相同的方法添加一张像这样的新照片

     self.picPostPicImageCache.setObject(UIImage(data:imageData)!,forKey: urlString as NSString)// new photo
但是,这会将图像添加到缓存的末尾,并将图像显示在tableview的底部,而不是顶部。我想将其添加到缓存的开头。在不删除缓存中的元素并重新加载的情况下,有没有可能做到这一点