PSCollectionView的代表不触发 [英] PSCollectionView's delegate not fire

查看:71
本文介绍了PSCollectionView的代表不触发的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在 Github 上关注了PSCollectionView的用法.

I followed PSCollectionView's usage on Github.

这是我的代码:

- (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]时,结果如下:

My console was empty. But when I called [collectionView reloadData], here is the result:

num rows
height for row
height for row
num rows

我不知道为什么没有打印出行单元格".

I have no idea why "cell for row" is not printed out.

有任何提示或建议吗?谢谢.

Any hint or suggestion? Thank you.

推荐答案

最后我可以使它起作用了!

Finally I can make it works!

您必须设置PSCollectionView实例的框架.

You must set the PSCollectionView instance's frame.

这篇关于PSCollectionView的代表不触发的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆