2013-04-25 71 views
0

我有一个故事板项目,我添加了PSTCollectionview类和所有文件。然后我为我的viewcontroller“allbooks.h,.m在PSUICollectionviewcontroller_”中创建了一个类,并且iam无法将这个类添加到我的viewcontroller中?请PSTCollectionview不适合我吗?

GMMAllBooksGrid.h

#import <UIKit/UIKit.h> 

@interface GMMAllBooksGrid : PSUICollectionViewController 
@end 
+0

我不明白你的问题。尝试更详细地解释。尝试编辑您的文章以包含allbooks.h的内容。 – 2013-04-25 05:59:35

+0

你必须添加PSTCollectionView以编程方式显示你的代码? – 2013-04-25 06:00:29

回答

6

可以使用PSTCollectionView以同样的方式为UICollectionView。我会后我的代码可以帮助你。

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