【问题标题】:How to use PSTCollectionView in a project targeted to iOS 5?如何在针对 iOS 5 的项目中使用 PSTCollectionView?
【发布时间】:2013-04-23 16:18:07
【问题描述】:

在一个针对 iOS 5.1(最低)的项目上工作,我使用PSTCollectionView 来创建一个非常简单的流布局视图。 PSTCollectionView 应该适用于 iOS 5.1,但 CollectionView 仅适用于 iOS 6.1 模拟器。在 iOS 5.1 模拟器中运行时,可以看到CollectionView 的背景颜色,但没有单元格。

设置CollectionView的代码是:

-(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];
}

}

是否需要额外的配置?

我做错了吗?

我正在使用 iOS 5.1 和 iOS 6.1 模拟器。

【问题讨论】:

  • BookshelfViewCell 的父类是什么?
  • @quellish,父类是PSUICollectionViewCell。

标签: iphone ios objective-c pstcollectionview


【解决方案1】:

我在 iOS 5 上使用了 PSTCollectionView,尽管我使用了自定义布局而不是内置的流布局,因为我需要水平和垂直滚动。也许我的例子会帮助你。 https://github.com/neildavis/MyCollectionView

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多