title: iOS6 UICollectionView and UIPageControl - How to get visible cell?
body: <p>While studying iOS6 new features I got a question about <a href="http://developer.apple.com/library/ios/#documentation/uikit/reference/UICollectionView_class/Reference/Reference.html" rel="noreferrer" title="UICollectionView Class reference">UICollectionView</a>.<br/>
  I am currently testing it with Flow layout and the scroll direction set to horizontal, scrolling and paging enabled. I've set its size to exactly the same as my custom's cells, so it can show one at a time, and by scrollig it sideways, the user would see the other existing cells.</p>
  
  <p>It works perfectly.</p>
  
  <p>Now I want to add and <a href="http://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPageControl_Class/Reference/Reference.html" rel="noreferrer" title="UIPageControl Class reference">UIPageControl</a> to the collection view I made, so it can show up which cell is visible and how many cells are there.</p>
  
  <p>Building up the page control was rather simple, frame and numberOfPages defined.</p>
  
  <p>The problem I am having, as the question titles marks, is how to get which cell is currently visible in the collection view, so it can change the currentPage of the page control.</p>
  
  <p>I've tried delegate methods, like cellForItemAtIndexPath, but it is made to load cells, not show them. didEndDisplayingCell triggers when a cell its not displayed anymore, the opposite event of what I need.</p>
  
  <p>Its seems that -visibleCells and -indexPathsForVisibleItems, collection view methods, are the correct choice for me, but I bumped into another problem. When to trigger them?</p>
  
  <p>Thanks in advance, hope I made myself clear enough so you guys can understand me!</p>