Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/97.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 如何通过数组使用SDImage在swift中显示图像_Ios_Swift - Fatal编程技术网

Ios 如何通过数组使用SDImage在swift中显示图像

Ios 如何通过数组使用SDImage在swift中显示图像,ios,swift,Ios,Swift,这里我在imageView中显示图像。我能够显示图像,但只能在TableView的所有行中显示单个图像。我第一次将SDWebImage与swift一起使用。因此,我想在下面的代码中传递数组,以显示每行中的相应图像。在这里,我通过将名称传递到数组来成功显示名称,现在我只想显示图像 注意:请参见下面注释中的代码,但其给定错误希望传递相同的数组,但不知道如何使用swift编写 func tableView(tableView: UITableView, cellForRowAtIndexPath in

这里我在
imageView
中显示图像。我能够显示图像,但只能在
TableView
的所有行中显示单个图像。我第一次将SDWebImage与swift一起使用。因此,我想在下面的代码中传递数组,以显示每行中的相应图像。在这里,我通过将名称传递到数组来成功显示名称,现在我只想显示图像

注意:请参见下面注释中的代码,但其给定错误希望传递相同的数组,但不知道如何使用swift编写

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell : TableViewCell = self.tableView.dequeueReusableCellWithIdentifier("Cell") as! TableViewCell        
    let strTitle : NSString = arrDict[indexPath.row].valueForKey("clip_name") as! NSString        
    cell.clipName.text = strTitle as String 
    cell.videoImage.sd_setImageWithURL(NSURL(string:"http://example.com/test/images/clips", arrDict(indexPath.r‌​ow).objectForKey("clip_image_path")))    
    return cell

}

您需要像这样用
URL
附加图像名称

let imagePath = String(format: "http://example.com/test/images/clips/%@",arrDict[indexPath.row].valueForKey("clip_image_path") as! NSString)
cell.videoImage.sd_setImageWithURL(NSURL(string: imagePath))

很抱歉,您遇到了什么样的错误?没有错误,但我想将数组传递给它,因为我有许多图像,就像我用于显示名称的方式一样,我必须显示所有图像看到注释代码不确定到底是什么问题,但您是否尝试过以设置标题的方式执行此操作<代码>让imageUrl=NSString=arrDict[indexath.row].valueForKey(“剪辑图像路径”)为!NSString cell.videoImage.sd_setImageWithURL(NSURL(string:imageUrl))现在查看代码我必须使用url和值作为键来传递代码,但不知道如何正确编写@Fikson你能发布你遇到的问题类型以及为什么不能使用
valueForKey
?现在查看代码我必须使用url和值作为键来传递代码,但不知道如何编写它正确,我认为
clip\u image\u path
键包含图像的url谢谢@Nirav的帮助