CEWendel / SWTableViewCell

An easy-to-use UITableViewCell subclass that implements a swippable content view which exposes utility buttons (similar to iOS 7 Mail Application)
MIT License
7.14k stars 1.27k forks source link

Using static buttons in SWTableViewCell and scrolling to another SWTableViewCell clears the buttons #396

Closed Jeroenbb94 closed 7 years ago

Jeroenbb94 commented 7 years ago

I've got a tableview controller with several tableViewCells. Some of the cells are subclassing SWTableViewCells. In 'cellForItemAtIndexPath' the right buttons are being set and they display aswell when the user swipes the cell. However, if the user continuos to scroll to another SWTableViewCell (sometimes there are 3-5 cells in between) the right buttons are gone from the first cell.

If the user opens (swipe) the second cell, the buttons are there. But if the user scrolls down so that the first cell is out of the visible screen, and scrolls back to the first cell. The second cell loses its buttons and the first cell got its buttons again.

How can I fix this problem?

Jeroenbb94 commented 7 years ago

Found the problem, if you defined the RightButtons as a static variable it will have the effect I described. If you initialise the buttons in 'cellForRowAtIndexPath' instead, it works perfect :)