我正在使用UITableView
來顯示我的數據。圖像在滾動時消失UITableView
我的數據由圖像和文字組成。問題是當我滾動UITableView
圖像消失。
這是我的代碼:
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return msgs.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! collCell
let msg = msgs[indexPath.row]
var decodeImgURL = ""
cell.lbl1.text = msg.content
decodeImgURL = msg.imgurl
if decodeImgURL == "none" {
cell.img.isHidden = true
} else {
let dataDecoded : Data = Data(base64Encoded:decodeImgURL,options: .ignoreUnknownCharacters)!
let decodedImage = UIImage(data: dataDecoded)
cell.img.image = decodedImage
}
return cell
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
let msg = msgs[indexPath.row]
if msg.imgurl == "none" {
return 64
} else {
return 207
}
}
'lbl1'中的'msg.content'也消失了嗎? – thedjnivek
你的形象甚至出現在第一位? –
@thedjnivek否lbl1保持不變 –