Problem with CollectionView iOS 6

I am working on a project, it has a number of images displayed as a collection of web data.

I implemented a collection view of the WaterFlowLayout Github Open Source Project https://github.com/aceisScope/WaterflowView

Images are dynamically assigned to an array of collection images.

It works fine if the collection view source has 3 or more images.

But if the number of images to display is less than 3, than it is not displayed as a collection. In the demo project, the same thing happens.

one more thing that I implemented for updating, but inside and almost 12 images can be displayed on one page, and if the number of images is more than 13 than the default scroll for the collection, it works fine and can be pulled out to update, but if the image count is less than 12 than I cannot access to update the colletion view.

if numberOfItemsInSection is 3, and numberOfColumnsInFlowLayout is also 3 means that it completed one full row, than the code will work fine.

- (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 3; } #pragma mark- UICollectionViewDatasourceFlowLayout - (NSInteger)numberOfColumnsInFlowLayout:(WaterFlowLayout*)flowlayout { return 3; } 

but if numberOfItemsInSection is 2, and numberOfColumnsInFlowLayout is also 3, then it doesn’t complete one full line, I can’t display the images.

  - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section { return 2; } #pragma mark- UICollectionViewDatasourceFlowLayout - (NSInteger)numberOfColumnsInFlowLayout:(WaterFlowLayout*)flowlayout { return 3; } 

and can someone also suggest some trick to enable pull to update even if the default scroll of the sort is not active.

Thanks in advance...

+6
source share
1 answer

Perhaps you should skip the WaterFlowLayout repository and use the UICollectionView instead:

  • To get started with UICollectionView, take a look at this great Brian Hansen tutorial . He will introduce you to the UICollectionView.

  • If you are using a UICollectionView, you can add a pull-to-refresh control with just a few lines of code in your UICollectionViewController viewDidLoad method:

     UIRefreshControl *refreshControl = [[UIRefreshControl alloc] init]; [refreshControl addTarget:self action:@selector(startRefresh:) forControlEvents:UIControlEventValueChanged]; [self.collectionView addSubview:refreshControl]; 
  • To implement a Pinterest-style waterfall layout, you can use this github UICollectionViewLayout repository or any number of other repositories that are there: https://github.com/jayslu/JSPintDemo

+4
source

All Articles