Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/59.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 表视图单元格中不显示图像_Ios_Mysql_Swift - Fatal编程技术网

Ios 表视图单元格中不显示图像

Ios 表视图单元格中不显示图像,ios,mysql,swift,Ios,Mysql,Swift,strong text我正在尝试将图像从Unsplash API下载到表视图中,但由于某些原因,它没有显示在表视图单元格中。根据文档,下载图像应该像这样“photo.url.raw” 下面是下载图像的逻辑。我如何解决这个问题 链接: 如果您尝试设置调试点并检查流,您将发现您对以下代码的和平性存在问题: let cacheKey = NSString(string: urlString) //creates cacheKey to store in image variable let i

strong text我正在尝试将图像从Unsplash API下载到表视图中,但由于某些原因,它没有显示在表视图单元格中。根据文档,下载图像应该像这样“photo.url.raw” 下面是下载图像的逻辑。我如何解决这个问题

链接:


如果您尝试设置调试点并检查流,您将发现您对以下代码的和平性存在问题:

let cacheKey = NSString(string: urlString) //creates cacheKey to store in image variable
    let imagesBaseURLSTring = imageURL.urls?.thumb ?? "No image"
    // Here imagesBaseURLSTring is nil, so image is not downloaded and it is completed with nil. imagesBaseURLSTring is nil because of imageURL.urls is nil
    guard let url = URL(string: imagesBaseURLSTring) else {
        completed(nil)
        return
    }
这里imagesBaseURLSTring是nil,所以不下载图像,而是用nil完成。imagesBaseURLSTring为零,因为imageURL.URL为零。请检查您的逻辑,为什么为零

仅为了测试下载部件,您可以通过以下方式进行检查:

//let imagesBaseURLSTring = imageURL.urls?.thumb ?? "No image"
let imagesBaseURLSTring = urlString
//let imagesBaseURLSTring = imageURL.urls?.thumb ?? "No image"
let imagesBaseURLSTring = urlString