Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/17.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
Swift 如何修复从URL下载并设置为GMSMarker后闪烁的图像?_Swift_Google Maps_Google Maps Markers - Fatal编程技术网

Swift 如何修复从URL下载并设置为GMSMarker后闪烁的图像?

Swift 如何修复从URL下载并设置为GMSMarker后闪烁的图像?,swift,google-maps,google-maps-markers,Swift,Google Maps,Google Maps Markers,这就是我到目前为止所做的。当我调用函数apply image时,视图中的所有标记都设置了它们的图像,但是当我缩小地图并检查其他标记时,问题就会出现,它们的图像会一直闪烁,并且不会停止。我也希望我的图像是圆形的,但它们不断变成六边形 制造商的行为有点像可重复使用的细胞,所以将图像保存到缓存将提高您的性能。这样做翠鸟是一个很好的图书馆。在安装和导入之后,您可以在您的案例中这样使用它 func applyImage(from url: URL, to marker: GMSMarker) {

这就是我到目前为止所做的。当我调用函数apply image时,视图中的所有标记都设置了它们的图像,但是当我缩小地图并检查其他标记时,问题就会出现,它们的图像会一直闪烁,并且不会停止。我也希望我的图像是圆形的,但它们不断变成六边形


制造商的行为有点像可重复使用的细胞,所以将图像保存到缓存将提高您的性能。这样做翠鸟是一个很好的图书馆。在安装和导入之后,您可以在您的案例中这样使用它

func applyImage(from url: URL, to marker: GMSMarker) {
    let imageView = UIImage()
    imageView.frame = CGRect.init(x: 0, y: 0, width: 44, height: 44)

    let identifier =  "\(a specific name for each of your markers, could be coordinates or adress)"
    let url = URL(string: "your url")!
            let resource = ImageResource(downloadURL: url, cacheKey: identifier)
            imageView.kf.setImage(with: resource, placeholder: UIImage(named: 
          "placeholderIfYouHave.png")! )
    }
}

制造商的行为有点像可重复使用的细胞,所以将图像保存到缓存将提高您的性能。这样做翠鸟是一个很好的图书馆。在安装和导入之后,您可以在您的案例中这样使用它

func applyImage(from url: URL, to marker: GMSMarker) {
    let imageView = UIImage()
    imageView.frame = CGRect.init(x: 0, y: 0, width: 44, height: 44)

    let identifier =  "\(a specific name for each of your markers, could be coordinates or adress)"
    let url = URL(string: "your url")!
            let resource = ImageResource(downloadURL: url, cacheKey: identifier)
            imageView.kf.setImage(with: resource, placeholder: UIImage(named: 
          "placeholderIfYouHave.png")! )
    }
}

谢谢,我试试看!如果有用的话,请别忘了把它标记为真的,谢谢谢谢,我会试试的!如果有帮助的话,请别忘了把它标记为真的,谢谢