(iOS) SKCanvasView issue on table view cell reuse #1649
-
Hello everyone. I have an issue with SKCanvasView drawings beeing incorrectly drawn AFTER cell reuse. Basically I am using a custom cell in a xib file and with a view, in this view I am drawing a segmented progress bar. The first time the table cells are rendered correctly, but after scrolling down and up again, the contents on the not visible cells get messed up after reappearing. Not reusing cells is not an option as I have many items in the list. The OnPaint event is set up in the view cell class, not on the viewmodel. Basically I am searching for a way to not have to redraw on the cell item canvas each time the cell is reused. This means I want the cells to keep its data, even after reused by the UITableView. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Not sure I understand what you mean. You are asking for a way for the view to remember the image that was drawn but also reuse the cell? So basically just render once and swap out? This is technically possible by caching the image you draw, or not even use a canvas view and draw offscreen. You could have a custom image view that sets the source from a cache, which can be rendered once by creating your own surface. But, since SkiaSharp is pretty fast and you also want to support the case of view resizes (eg the device rotates) it is just simpler to redraw the view and not have to worry about the cache. And, Caches use memory which will be an issue if you have loads of items. |
Beta Was this translation helpful? Give feedback.
-
I was able to solve my problem by setting the cell properties before reusing the cell. Caching the drawn image did cross my mind though. Thanks for the help. |
Beta Was this translation helpful? Give feedback.
I was able to solve my problem by setting the cell properties before reusing the cell. Caching the drawn image did cross my mind though. Thanks for the help.