我有一个故事板项目,我添加了PSTCollectionview类和所有文件。然后我为我的viewcontroller创建了一个类" allbooks.h,.m in" PSUICollectionviewcontroller _"并且我无法在我的viewcontroller上添加这个类???请
GMMAllBooksGrid.h
#import <UIKit/UIKit.h>
@interface GMMAllBooksGrid : PSUICollectionViewController
@end
答案 0 :(得分:6)
您可以像 UICollectionView 一样使用 PSTCollectionView 。我会发布我的代码可能对你有帮助。
CollectionViewController.h
#import <UIKit/UIKit.h>
#import "PSTCollectionView.h"
@interface CollectionViewController : UIViewController <PSUICollectionViewDataSource,PSUICollectionViewDelegate,PSUICollectionViewDelegateFlowLayout>
@property(nonatomic,retain) PSUICollectionView *collectionView;
@end
CollectionViewController.m
-(void)loadView
{
[super loadView];
self.view.backgroundColor = [UIColor whiteColor];
PSUICollectionViewFlowLayout *layout = [[PSUICollectionViewFlowLayout alloc] init];
// Configure layout attributes globally
layout.itemSize = CGSizeMake(150, 150);
self.collectionView = [[[PSUICollectionView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds)) collectionViewLayout:layout]autorelease];
[self.collectionView setDelegate:self];
[self.collectionView setDataSource:self];
[self.collectionView setAutoresizingMask:UIViewAutoresizingFlexibleHeight |UIViewAutoresizingFlexibleWidth| UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin];
[self.collectionView setBackgroundColor:[UIColor clearColor]];
// Register Cell and supplimentary views
[self.collectionView registerClass:[PSUICollectionViewCell class] forCellWithReuseIdentifier:CELL_ID];
[self.view addSubview:_collectionView];
}