Я успешно выбрал метку пользовательского интерфейса и отобразил ее, но не уверен, как получить изображение.
Я попытался скопировать вставить тот же каркас для изображения, но он сказал, что вы не можете использовать Stringдля изображения в этой форме:
let x = y?["PhotoPost"]
////Here is what I have for the label:
public override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! ViewControllerTableViewCell
let person: Userx = people[indexPath.row]
cell.lblName.text = person.Education
table.dataSource = self
table.delegate = self
return cell
}
databaseRef.observe(DataEventType.value, with: {snapshot in
if snapshot.childrenCount>0{
self.people.removeAll()
for people in snapshot.children.allObjects as! [DataSnapshot] {
let peopleObject = people.value as? [String: AnyObject]
let peopleEducation = peopleObject?["Education"]
let peoplePhotoPosts = peopleObject?["PhotoPosts"]
let peopl = Userx(Education: peopleEducation as! String?, PhotoPosts: peoplePhotoPosts as AnyObject)
self.people.append(peopl)
}
self.table.reloadData()
}
})
//// Вот предварительный код, который я имею для постановки картины
import SDWebImage.
///installed in pod already
cell.imageView?.image = UIImage(named: "il_570xN.1325825023_m2nl")
if let PhotoPosts = person.PhotoPosts {
let url = URL(string: PhotoPosts)
cell.imageView?.sd_setImage(with: url)
URLSession.shared.dataTask(with: (url)!, completionHandler: {(data, response, error) in
if error != nil {
print(error as Any)
return
}
DispatchQueue.main.async{
cell.imageView?.image = UIImage(data: data!)
}
}).resume()
}
return cell
}
У меня также естьпроблема фотопостов, по-видимому, в словаре, а не в строке.Я не уверен, где он будет установлен в качестве словаря, потому что в этом файле и в его классе все строки.