I am creating a chatting Application but when I reload the cell some of the views gets cloned for few ms. Can anyone guide me here whats wrong is happening. following is my code for TableViewCell:
class TxtMsgSenderCell: UITableViewCell {
func configureCellWith(msgModel: MessageModel) {
if msgModel.msgStatus == 1 {
self.activityIndicator.startAnimating()
self.btnError.isHidden = true
self.imgViewReadStatus.isHidden = true
self.lblMsgStatus.isHidden = true
} else if msgModel.msgStatus == 2 {
self.activityIndicator.stopAnimating()
self.btnError.isHidden = true
self.lblMsgStatus.isHidden = false
let receiverId = self.getReceiverId(arrIDs: Array(msgModel.members))
if receiverId.isEmpty {
self.imgViewReadStatus.isHidden = true
self.lblMsgStatus.text = "Sent"
} else {
if msgModel.seenBy.contains(receiverId) {
self.imgViewReadStatus.isHidden = true
self.imgViewReadStatus.image = UIImage(named: "read")
self.lblMsgStatus.text = "Seen"
} else if msgModel.deliveredTo.contains(receiverId) {
self.imgViewReadStatus.isHidden = true
self.imgViewReadStatus.image = UIImage(named: "unread")
self.lblMsgStatus.text = "Delivered"
} else {
self.imgViewReadStatus.isHidden = true
self.lblMsgStatus.text = "Sent"
}
}
} else {
self.activityIndicator.stopAnimating()
self.btnError.isHidden = false
self.imgViewReadStatus.isHidden = true
self.lblMsgStatus.isHidden = true
}
self.lblMessage.text = msgModel.message
if let timestampInMs = Double(msgModel.createdAt) {
let msgDate = Date(timeIntervalSince1970: timestampInMs*0.001)
self.lblTime.text = msgDate.timeAgoSince
}
}
}
See, here I am having just one UILabel for showing time but I can see two different labels in the same cell for sometime.