A
A
Anton Yeskin2014-02-20 10:35:54
Objective-C
Anton Yeskin, 2014-02-20 10:35:54

Is it possible to tell a UICollectionView to call cellForItemAtIndexPath on neighbors from the current UICollectionViewCell?

There is a UICollectionView in which UICollectionViewCell is paged through.
Each UICollectionViewCell is the size of a full page, i.e. only 1 UICollectionViewCell is displayed at rest and 2 UICollectionViewCell on page change.
The UICollectionViewCell has pictures that start loading only after the UICollectionViewCell is created in the cellForItemAtIndexPath method.
Thus, the picture is loaded and displayed after the new UICollectionViewCell has arrived in the viewport.
Question: Is it possible to tell a UICollectionView to call cellForItemAtIndexPath on neighbors of the current UICollectionViewCell that are not yet displayed on the screen? So that the picture could be loaded even outside the scope?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Petr Marochkin, 2014-02-20
@petun

Your objects are stored in some array (most likely), and when you call cellForItemAtIndexPath, you just need to take the next element of the array - indexPath.row+1, from there take the link to the image, load it asynchronously, and then add it to some cache.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question