Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • display data in two columns in collection view

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 2.37k
    Comment on it

    We can display data in two columns in a collection view. In below code we are dividing the width of the cell into two parts of the collection view.

     

    - (CGSize)collectionView:(UICollectionView *)collectionView
                      layout:(UICollectionViewLayout *)collectionViewLayout
      sizeForItemAtIndexPath:(NSIndexPath *)indexPath
    {
    
                  return CGSizeMake(collectionViewOutlet.frame.size.width/2-10, collectionViewOutlet.frame.size.width/2-10);
     
    }
    
    

     

    For this we can use the sizeForItemAtIndexPath delegate method of UICollectionView. As the name suggests this method returns the size of collection view item. In above code we are dividing the width of the cell into two parts of the collection view and as a result collection view will set two columns of items.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: