Search code examples
iphoneiosobjective-cpstcollectionview

How to use PSTCollectionView in a project targeted to iOS 5?


Working on a project which is targeted for iOS 5.1 (minimum), I'm using PSTCollectionView for creating a very simple flow layout view. PSTCollectionView is supposed to work on iOS 5.1, but the CollectionView only works on iOS 6.1 simulator. When I run it in iOS 5.1 simulator, I can see the background color of the CollectionView, but no cells.

The code for setting up the CollectionView is:

-(void)loadCollectionView
{
    if (!_collectionView) {
        PSUICollectionViewFlowLayout *collectionViewFlowLayout = [[PSUICollectionViewFlowLayout alloc] init];

        [collectionViewFlowLayout setScrollDirection:UICollectionViewScrollDirectionVertical];
        [collectionViewFlowLayout setItemSize:CGSizeMake(256, 196)];
        [collectionViewFlowLayout setHeaderReferenceSize:CGSizeMake(500, 30)];
        [collectionViewFlowLayout setFooterReferenceSize:CGSizeMake(500, 50)];
        [collectionViewFlowLayout setMinimumInteritemSpacing:0];
        [collectionViewFlowLayout setMinimumLineSpacing:0];
        [collectionViewFlowLayout setSectionInset:UIEdgeInsetsMake(10, 0, 20, 0)];

        _collectionView = (PSTCollectionView*)[[PSUICollectionView alloc] initWithFrame:CGRectMake(0,0,self.view.frame.size.width,self.view.frame.size.height) collectionViewLayout:collectionViewFlowLayout];
        [_collectionView setDelegate:self];
        [_collectionView setDataSource:self];
        [_collectionView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin];
        [_collectionView setBackgroundColor:BOOLSHELF_BACKGROUND_COLOR];
        [_collectionView registerClass:[BookshelfViewCell class] forCellWithReuseIdentifier:cellIdentifier];
    [self.view addSubview:_collectionView];
}

}

Are there any additional configurations needed?

Am I doing something wrong?

I'm using iOS 5.1 and iOS 6.1 simulators.


Solution

  • I have used PSTCollectionView on iOS 5, although I used a custom layout instead of the built in flow layout since I needed to scroll horizontally and vertically. Maybe my example will help you though. https://github.com/neildavis/MyCollectionView