{"id":7878,"date":"2015-11-04T20:49:50","date_gmt":"2015-11-04T20:49:50","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2015\/11\/04\/uicollectionview-infinite-scroll-reuses-index-paths-and-clears-content-open-source-projects-infinite-scroll-infinite-scroll\/"},"modified":"2015-11-04T20:49:50","modified_gmt":"2015-11-04T20:49:50","slug":"uicollectionview-infinite-scroll-reuses-index-paths-and-clears-content-open-source-projects-infinite-scroll-infinite-scroll","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2015\/11\/04\/uicollectionview-infinite-scroll-reuses-index-paths-and-clears-content-open-source-projects-infinite-scroll-infinite-scroll\/","title":{"rendered":"UICollectionView infinite scroll: reuses index paths and clears content-open source projects infinite-scroll\/infinite-scroll"},"content":{"rendered":"<p>Using the answer from a previous question, I made an infinite scroll. However, I have a problem when scrolling.<\/p>\n<p>It seems that for a millisecond, the <code>UICollectionView<\/code> (or maybe the <code>UIScrollView<\/code> for that matter) thinks the cells shown are not visible anymore, thus reuses the cells for new cells. This leads to cells being double used when scrolling. The reason I believe this is the cause of my problem is because the &#8220;cheat&#8221; one uses in order to be able to infinite scroll is to reset the <code>contentOffset<\/code> of the <code>UIScollView<\/code>.<\/p>\n<p>The cells of my <code>UICollectionView<\/code> contain a background image which is downloaded asynchronously (of fetched from cache) using <code>MKNetworkKit<\/code>. One of the other side effects is that when scrolling a view &#8220;screen lenghts&#8221; in a row, the screen gets truncated. Almost as if a reloadData occurred in the <code>UIScrollView<\/code>, yet the code doesn&#8217;t reload the data at all.<\/p>\n<p>My question is: How can I prevent the <code>UICollectionView<\/code> from reusing visible cells and from truncating the view suddenly?<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using the answer from a previous question, I made an infinite scroll. However, I have a problem when scrolling. It seems that for a millisecond, the UICollectionView (or maybe the UIScrollView for that matter) thinks the cells shown are not visible anymore, thus reuses the cells for new cells. This leads to cells being double [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-7878","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7878","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=7878"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/7878\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=7878"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=7878"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=7878"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}