【发布时间】:2020-12-10 11:39:29
【问题描述】:
我有一个包含 2 个自定义单元格、发送方和接收方单元格的聊天应用程序。填充单元格后,只能单击带有“显示图像”文本的单元格。我正在尝试单击这些单元格,以便
- 我可以隐藏标签
- 我可以显示来自 url 的图片
点击功能有效,但我无法执行上述步骤。请帮忙,因为我不知道该怎么做
这是我的代码
@objc
func tapFunctionCell(sender:UITapGestureRecognizer) {
print("tap again sen")
let tapLocation = sender.location(in: tblViewChat)
let indexPath = self.tblViewChat.indexPathForRow(at: tapLocation)
let position = indexPath?.row ?? 0
print(position)
let cell = tblViewChat.dequeueReusableCell(withIdentifier: "senderCell") as! SenderTblCell
cell.lblMessage.isHidden = true
let url = URL(string:objChatVM.getMessage(index:position))
print(url)
cell.ImageB.kf.setImage(with:url)
cell.ImageB.isHidden = false
}
@objc
func tapFunction(sender:UITapGestureRecognizer) {
print("tap again receive")
let cell2 = tblViewChat.dequeueReusableCell(withIdentifier: "receiverCell") as! ReceiverTblCell
cell2.lblMessage.isHidden = false
let tapLocation = sender.location(in: tblViewChat)
let indexPath = self.tblViewChat.indexPathForRow(at: tapLocation)
let position = indexPath?.row ?? 0
print(position)
let url = URL(string:objChatVM.getMessage(index:position))
print(url)
cell2.imageButton.kf.setImage(with:url)
cell2.imageButton.isHidden = false
}
【问题讨论】:
标签: swift uitableview tableview custom-cell