Vote count:
0
This question will probably get downvoted and closed but I'm struggling while learning how to read the "collectionview indexPathsForVisibleItems". I'm trying to implement lazy loading and I know there are many examples out there but while I'm learning, I can't figure out how to implement them. I have a collection view with 3 images across and 2 and a half rows visible when the viewcontroller loads. In my cellForItemAtIndexPath: I'm logging this:
NSArray *visible = [collectionView indexPathsForVisibleItems];
NSLog(@"%@", visible);
for (NSIndexPath *index in visible){
NSLog(@"%d", index.row);
}
The output is:
2014-04-22 19:51:35.832 Test App[55175:60b] (
)
2014-04-22 19:51:35.834 Test App[55175:60b] (
"<NSIndexPath: 0xaac4f30> {length = 2, path = 0 - 0}"
)
2014-04-22 19:51:35.834 Test App[55175:60b] 0
2014-04-22 19:51:35.835 Test App[55175:60b] (
"<NSIndexPath: 0xaac4f30> {length = 2, path = 0 - 0}",
"<NSIndexPath: 0xaac5030> {length = 2, path = 0 - 1}"
)
2014-04-22 19:51:35.835 Test App[55175:60b] 0
2014-04-22 19:51:35.835 Test App[55175:60b] 1
2014-04-22 19:51:35.836 Test App[55175:60b] (
"<NSIndexPath: 0xaac50c0> {length = 2, path = 0 - 2}",
"<NSIndexPath: 0xaac4f30> {length = 2, path = 0 - 0}",
"<NSIndexPath: 0xaac5030> {length = 2, path = 0 - 1}"
)
2014-04-22 19:51:35.836 Test App[55175:60b] 2
2014-04-22 19:51:35.837 Test App[55175:60b] 0
2014-04-22 19:51:35.837 Test App[55175:60b] 1
2014-04-22 19:51:35.838 Test App[55175:60b] (
"<NSIndexPath: 0xaac4f30> {length = 2, path = 0 - 0}",
"<NSIndexPath: 0xaac50c0> {length = 2, path = 0 - 2}",
"<NSIndexPath: 0xaac5030> {length = 2, path = 0 - 1}",
"<NSIndexPath: 0xaac5150> {length = 2, path = 0 - 3}"
)
2014-04-22 19:51:35.838 Test App[55175:60b] 0
2014-04-22 19:51:35.839 Test App[55175:60b] 2
2014-04-22 19:51:35.839 Test App[55175:60b] 1
2014-04-22 19:51:35.839 Test App[55175:60b] 3
And so on. And as I scroll, the values change. How do I make sense of these values? Do they indicate which cells are on the screen? If so, how? Row-cell? I'm confused. I know I will use the didEndDisplayingCell: to cancel the NSOperation...but which value should I check for? Long question for probably a simple explanation. Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire