我的圖像沒有顯示在我的新視圖中,它顯示我的控制檯中的網址,但不是在模擬器或設備上。我從Firebase獲取數據並將其發送到名爲User的類。然後數據顯示在我的tableViewCell上,然後繼續使用新的ViewController,但圖像視圖是空白的。tableViewCell圖像到新視圖
//我的代碼爲tableViewController
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "prefCell", for: indexPath) as! SFPTableViewCell
let user = userList[indexPath.row]
cell.name.text = userList[indexPath.row].name
cell.location.text = userList[indexPath.row].location
cell.bio.text = userList[indexPath.row].bio
if let imageURL = user.image {
cell.imageOne.loadImageUsingCacheWithUrlString(urlString: imageURL)
}
return cell
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if let destination = segue.destination as? SFProfileViewController{
let cell = sender as! UITableViewCell
let selectedRow = tableView.indexPath(for: cell)!.row
destination.nameProfile = userList[selectedRow].name!
destination.locationProfile = userList[selectedRow].location!
destination.imageOneUrl = userList[selectedRow].image!
}
}
//我的目的地的ViewController
class SFProfileViewController: UIViewController, UITableViewDelegate {
@IBOutlet weak var nameLabelTwo: UILabel!
var user: User?
var userList = [User]()
@IBOutlet weak var imageOne: UIImageView!
var imageURL: String?
var imageOneUrl: String!
var nameProfile : String!
var locationProfile: String!
@IBOutlet weak var nameLabel: UILabel!
@IBOutlet weak var locationLabel: UILabel!
override func viewWillAppear(_ animated: Bool) {
print(locationProfile)
print(nameProfile)
print(imageOneUrl)
imageOne.image = UIImage(named: imageOneUrl)
nameLabelTwo.text = String(describing: nameProfile!)
nameLabel.text = String(describing: nameProfile!)
locationLabel.text = String(describing: locationProfile!)
}
同我已經回答了你可能想給予好評的答案imageOne網址!而不是給一個新的! – Joe