我的代码:the following is my code!如何进入Firebase并获取我的图片网址,然后将其解码为UIImage,然后在Google地图中将图片显示为标记图标?
func queryImageWithCompletion(completion:((image:UIImage?)->Void)?) {
self.ref.child("users").child((userID)!).observeEventType(.Value, withBlock: { snapshot in
if let strUrl = snapshot.value as? String, url = NSURL(string: strUrl) {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), {
if let data = NSData(contentsOfURL: url), image = UIImage(data:data) {
dispatch_async(dispatch_get_main_queue(), {
completion?(image:image)
marker.icon = UIImage(data: data)
})
} else {
dispatch_async(dispatch_get_main_queue(), {
completion?(image:nil)
})
}
})
} else {
dispatch_async(dispatch_get_main_queue(), {
completion?(image:nil)
})
}
})
}
这是我使用的尝试显示图片作为标记图标的代码!谁能帮我。我没有得到任何错误,但它不会工作。
请发表你的代码,而不是它的屏幕截图。并解释你的错误或问题是 – TheValyreanGroup