Closed nor0x closed 9 years ago
The cells are reused. When you scroll down, you see section cells that have been item cells before. You need to explicitly set cell.label_OnOff.hidden = NO;
in cellForItemAtIndexPath
, when indexPath.item == 0
.
Additionally, you might want to check if a section is expanded or not before setting label_OnOff.text
like cell.label_OnOff.text = isExpanded ? @"-" : @"+";
for the same reason.
Thank you for the answer! -fixed it
Hello,
I have extended the Demo to display a + or a - label in the section cells. I use cellForItemAtIndexPath to hide the label on item cells:
To switch between + and - I implemented the delegate methods:
As you can see in the screenshot - the label is hidden on some section cells and some item cells. I don't know why this happens - indexPath.item == 0 should check if a specific cell is a section or an item? It seems that this issue is only present, if cells are not visible. After scrolling down and revealing new cells in the collection view - the label is not visible.