Reputation: 780
I have a custom xib table view cell that has a green uiview on it. The uiview acts as a new message indicator - whenever a message comes in, the green view is displayed. When a user taps the cell, I want to set the view to hidden. My only question is; how would I go about hiding the view just on that specific table view cell and not all table view cells?
Upvotes: 1
Views: 49
Reputation: 100523
Suppose your model
class Item {
var greenHidden = false
/// more properties
}
Then create the green view inside the xib and according to the current state do inside cellForRowAt
let cell = //
let item = arr[indexPath.row]
cell.greenView.isHidden = item.greenHidden
When the cell is tapped inside didSelectRowAt
do
arr[indexPath.row].greenHidden = true
self.tableView.reloadRows(at:[indexPath],with:.none)
Upvotes: 1