我跟着PSCollectionView的用法Github。PSCollectionView的代表不会启动
这是我的代码:
- (void)viewDidLoad
{
self.collectionView = [[PSCollectionView alloc] init];
self.collectionView.collectionViewDataSource = self;
self.collectionView.collectionViewDelegate = self;
self.collectionView.numColsPortrait = 2;
[self.view addSubview:self.collectionView];
[self.collectionView reloadData]; // If i don't call this my console will be empty.
}
- (NSInteger)numberOfRowsInCollectionView:(PSCollectionView *)collectionView
{
NSLog(@"num rows");
return 2;
}
- (PSCollectionViewCell *)collectionView:(PSCollectionView *)collectionView cellForRowAtIndex:(NSInteger)index
{
NSLog(@"cell for row");
return nil;
}
- (CGFloat)collectionView:(PSCollectionView *)collectionView heightForRowAtIndex:(NSInteger)index
{
NSLog(@"height for row");
return 0.0;
}
我的控制台是空的。但是,当我打电话[的CollectionView reloadData],这里是结果:
num rows
height for row
height for row
num rows
我不知道为什么“为行单元格”不打印出来。
任何暗示或建议?谢谢。
您是否在.h文件中添加了以下数据源 -? –
2013-05-10 06:55:43
我已将这些文件添加到.h文件中: –
2013-05-10 07:00:21
您是否链接过.xib文件? – 2013-05-10 07:03:08