Image cell reuse and cancellation
In a UIKit collection view with image cells, fast scrolling makes the previous request's response flash on a reused cell before it changes. What would you cancel when the cell is reused?
In a UIKit collection view with image cells, fast scrolling makes the previous request's response flash on a reused cell before it changes. What would you cancel when the cell is reused?
The cell keeps its in-flight image load Task in a property, and in prepareForReuse() it cancels that Task and clears the image view. Then configure starts a new Task for the new URL, and inside the Task the image is assigned only after checking for cancellation, so a late response never lands on the wrong cell.
ArchitectureShort answerAdvanced
On a UIKit cart screen, the product card is used in the list, in search, and in…
#uikit #collection-view
UIKitShort answerBasics
A tic-tac-toe game built with UIKit needs unlimited undo. What would you store to support…
#uikit
UIKitShort answerAdvanced
You're implementing flood fill on a large pixel grid drawn with a collection view (say…
#collection-view
UIKitShort answerBasics
A UIKit car listing cell has to grow in height and not truncate under the accessibility…
#uikit