【发布时间】:2018-06-08 16:32:11
【问题描述】:
我正在将图像字符串转换为 URL,但是当我转换它时,我在 URL 中得到了零值。 这是我的代码:
func tableView(_ tbldata: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tbldata.dequeueReusableCell(withIdentifier: "ServiceCheckCell", for: indexPath) as! ServiceCheckTableViewCell
cell.selectionStyle = .none
//save image in imagestr
let imagestr = (self.data[indexPath.row] as AnyObject).value(forKey:"service_image") as? String
let URLString = imagestr
//convert URLSting into URL
let URL = NSURL(string: URLString!)
cell.service_image.hnk_setImageFromURL(URL! as URL )
return cell
}
【问题讨论】:
-
尝试打印您的图片网址,如果格式不正确,将无法转换为网址
标签: swift