2013-04-25 47 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]; 
}