可以使用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];
}
我不明白你的問題。嘗試更詳細地解釋。嘗試編輯您的文章以包含allbooks.h的內容。 – 2013-04-25 05:59:35
你必須添加PSTCollectionView以編程方式顯示你的代碼? – 2013-04-25 06:00:29