我有一个故事板项目,我添加了 PSTCollectionview 类和所有文件。然后我在“PSUICollectionviewcontroller_”中为我的视图控制器“allbooks.h,.m”创建了一个类,但我无法在我的视图控制器上添加这个类???请
GMMAllBooksGrid.h
#import <UIKit/UIKit.h>
@interface GMMAllBooksGrid : PSUICollectionViewController
@end
我有一个故事板项目,我添加了 PSTCollectionview 类和所有文件。然后我在“PSUICollectionviewcontroller_”中为我的视图控制器“allbooks.h,.m”创建了一个类,但我无法在我的视图控制器上添加这个类???请
GMMAllBooksGrid.h
#import <UIKit/UIKit.h>
@interface GMMAllBooksGrid : PSUICollectionViewController
@end
您可以像使用UICollectionView一样使用PSTCollectionView。我将发布我的代码可能会对您有所帮助。
集合视图控制器.h
#import <UIKit/UIKit.h>
#import "PSTCollectionView.h"
@interface CollectionViewController : UIViewController <PSUICollectionViewDataSource,PSUICollectionViewDelegate,PSUICollectionViewDelegateFlowLayout>
@property(nonatomic,retain) PSUICollectionView *collectionView;
@end
集合视图控制器.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];
}