|An object for efficiently reusing views by recycling and dequeuing them from a pool of views. More...|
|The NIRecyclableView protocol defines a set of optional methods that a view may implement to handle being added to a NIViewRecycler. More...|
|A simple implementation of the NIRecyclableView protocol as a UIView. More...|
For recycling views in scroll views.
View recycling is an important aspect of iOS memory management and performance when building scroll views. UITableView uses view recycling via the table cell dequeue mechanism. NIViewRecycler implements this recycling functionality, allowing you to implement recycling mechanisms in your own views and controllers.
Imagine building a UITableView. We'll assume that a viewRecycler object exists in the view.
Views are usually recycled once they are no longer on screen, so within a did scroll event we might have code like the following:
This will take the views that are no longer visible and add them to the recycler. At a later point in that same didScroll code we will check if there are any new views that are visible. This is when we try to dequeue a recycled view from the recycler.