iOS PSTCollectionView使用注意点

转载自:https://github.com/steipete/PSTCollectionView


峰总帮我弄好的使用方法:(注意去设置layout)

- (void)initCollectionView

{

    data = @[

             @[@"One", @"Two", @"Three"],

             @[@"Four", @"Five", @"Six"],

             @[],

             @[@"Seven"],

             ];


    PSUICollectionViewFlowLayout *collectionViewFlowLayout = [[PSUICollectionViewFlowLayout alloc] init];

[collectionViewFlowLayout setScrollDirection:PSTCollectionViewScrollDirectionVertical];

[collectionViewFlowLayout setItemSize:CGSizeMake(76, 114)];

[collectionViewFlowLayout setHeaderReferenceSize:CGSizeMake(320, 30)];

[collectionViewFlowLayout setFooterReferenceSize:CGSizeMake(320, 50)];

[collectionViewFlowLayout setMinimumInteritemSpacing:10];

[collectionViewFlowLayout setMinimumLineSpacing:10];

[collectionViewFlowLayout setSectionInset:UIEdgeInsetsMake(10, 10, 20, 0)];

self.myCollectionView = [[PSUICollectionView alloc] initWithFrame:CGRectMake(floorf((CGRectGetWidth(self.view.bounds)-320)/2), 0, 320, CGRectGetHeight(self.view.bounds)) collectionViewLayout:collectionViewFlowLayout];

[self.myCollectionView setDelegate:self];

[self.myCollectionView setDataSource:self];

[self.myCollectionView setAutoresizingMask:UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin];

[self.myCollectionView setBackgroundColor:[UIColor redColor]];

[self.myCollectionView registerClass:[CollectionViewCell class] forCellWithReuseIdentifier:cellIdentifier];

[self.myCollectionView registerClass:[HeaderView class] forSupplementaryViewOfKind:PSTCollectionElementKindSectionHeader withReuseIdentifier:headerViewIdentifier];

[self.myCollectionView registerClass:[FooterView class] forSupplementaryViewOfKind:PSTCollectionElementKindSectionFooter withReuseIdentifier:footerViewIdentifier];

[self.view addSubview:self.myCollectionView];

}






由于ios6以下的版本不能支持 UICollectionView  所以在低版本的话只能使用第三方的PSTCollectionView

使用注意点:

1,PSTCollectionView要是arc的!这点非常关键  先将程序转为arc 然后吧把包拉进去 不要arc 支持的 可以添加 -fno-objc-arc 

转arc看 http://blog.csdn.net/linpeng_1/article/details/9770281

这里很重要的一点是:要确保objective C automatic reference  是 yes  (打auto 空格就会找到)专为arc 后PSTCollectionView 的相关文件不能是-fobjc-arc  所以 应该先转化arc 然后再包拉进去(经验)这个问题困扰了一整天 shit

PSTCollectionView的使用和UICollectionView 记本是一模一样的 有flowlayout  协议 等等 基本就是一模一样的用法 除了以上几个注意点


特别注意在ios7下 PSTCollectionView这个不怎么兼容  所以 我们应该 把里面所有的 PSUICollectionView 全部改为 PST打头的那个 就可以了



  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值