p1nt0z
p1nt0z

Reputation: 71

CollectionView Ios 6 issue

I am working on on project it has number of images displaying in collection view from web data.

I have implemented WaterFlowLayout collection view Open source Github project https://github.com/aceisScope/WaterflowView

Images are dynamically assigning to collection view image array..

It is working fine if collection view source have images count 3 or more..

But if image count to display is less than 3 than it is not displaying in collection view.. In demo project also its happening same..

one more thing i have implemented pull to refresh also but in and almost 12 images can be displaying in single page and if image count is more than 13 than collection default scrolling is working fine and i m able to pull to refresh but if image count is less than 12 than i am not able to access pull to refresh colletion view.

if numberOfItemsInSection is 3 and numberOfColumnsInFlowLayout is also 3 means its completes one full row than code will working 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 means its not completes one full row i am not able to display images.

    - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
    {
        return 2;
    }

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

and can anyone also suggest some trick to enable pull to refresh even if collation view default scrolling is not active..

Thanks in advance ...

Upvotes: 6

Views: 2306

Answers (1)

bryanjclark
bryanjclark

Reputation: 6434

You might consider skipping the WaterFlowLayout repository and just use UICollectionView instead:

  1. To get started with UICollectionView, take a look at this excellent tutorial by Bryan Hansen. It'll get you familiar with UICollectionView.

  2. If you're using UICollectionView, you can add a pull-to-refresh control with just a few lines of code in your UICollectionViewController's viewDidLoad method:

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

Upvotes: 4

Related Questions