How do I get a collection view cell's column number?

Discussion in 'iOS Programming' started by moonman239, Dec 19, 2013.

  1. moonman239 macrumors 68000

    Joined:
    Mar 27, 2009
    #1
    I have a collection view whose data is to be organized in rows and columns. The data is to be loaded programmatically. Unfortunately, the collection view doesn't seem to be built for data organized in this manner. (My thanks goes to the people who, in my previous thread on iterating through all of an object's keys, mentioned the possibility of using an enumerator.)
     
  2. moonman239 thread starter macrumors 68000

    Joined:
    Mar 27, 2009
    #2
    After giving this problem some thought, I decided to build a function that uses the visibleCells property of the collection view. If the count is zero, then the cell being generated is the first cell, so the cell is in the first column. If not, then the app will loop through each visible cell until it reaches a cell that is either at the end of the first row or at the end of the array.
     
  3. DannyBres macrumors 65816

    DannyBres

    Joined:
    Oct 30, 2007
    Location:
    UK
    #3
    could also use the visible cell's bound's origin to work out where on the screen it is?
     

Share This Page