Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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 ...

like image 790
p1nt0z Avatar asked Dec 20 '12 04:12

p1nt0z


People also ask

What is CollectionView?

A collection view manages an ordered set of content, such as the grid of photos in the Photos app, and presents it visually. Collection views are a collaboration between many different objects, including: Cells. A cell provides the visual representation for each piece of your content. Layouts.

Do CollectionView use cells?

CollectionView has no concept of cells. Instead, a data template is used to define the appearance of each item of data in the list.

How do I set up a CollectionView?

Add a CollectionView by pressing command shift L to open the storyboard widget window. Drag the collectionView onto the main view controller. Add constraints to the UICollectionView widget to ensure that the widget fills the screen on all devices. The foundation is now set up in the storyboard.

What is CollectionView delegate?

A collection view delegate manages user interactions with the collection view's contents, including item selection, highlighting, and performing actions on those items. The methods of this protocol are all optional. When configuring the collection view object, assign your delegate object to its delegate property.


1 Answers

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

like image 183
bryanjclark Avatar answered Oct 05 '22 22:10

bryanjclark