このコードに問題があります。基本的に私は、画像を使用してテーブルセルを作成しようとしています。ここのurlフィールドの値はhttp://pbs.twimg.com/profile_images/796924570150301696/35nSG5nN_normal.jpgですが、なんらかの理由でprint( "REACHED")は決して印刷されません。どんな助け/提案も感謝しています!TVViewのセルにTableViewを割り当てるテーブル
コードスニペット:
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: tIdentifier, for: indexPath) as! TweetCell
let tweet = tweets[indexPath.section][indexPath.row]
let url = tweet.user.profileImageURL!
print(url.absoluteString)
let data = try? Data(contentsOf: url)
if (data == nil){
} else {
print("REACHED")
cell.avatarImage = UIImage(data: data!)
}
cell.tweet = tweets[indexPath.section][indexPath.row]
return cell
}
'letデータ=試しますか?データ(contentsOf:url) 'それを避けてください!それはシンクロナイズでUIをブロックします。 – Larme
@Larme代替アプローチに関する提案はありますか? –
このライブラリは役に立ちます:https://github.com/Alamofire/AlamofireImage – Hapeki