使用我的自定义UICollectionViewLayout
子类时,cellForItemAtIndexPath:
不调用(我使用断点和调试输出进行了检查)。这就是我使用自定义布局的方式:
- (void)viewDidLoad
{
[super viewDidLoad];
DMSGridLayout* gridLayout = [[DMSGridLayout alloc] init];
// UICollectionViewFlowLayout* flow = [[UICollectionViewFlowLayout alloc] init];
// [flow setItemSize:CGSizeMake(150, 150)];
UICollectionView *collection = [[UICollectionView alloc] initWithFrame:self.view.bounds collectionViewLayout:gridLayout];
collection.delegate = self;
collection.dataSource = self;
self.collectionView = collection;
[self.view addSubview:self.collectionView];
[self.collectionView registerClass:[DMSGridCell class] forCellWithReuseIdentifier:@"CollectionCell"];
}
但是当我将上面的代码更改为使用UICollectionViewFlowLayout
而不是我的自定义子类时,cellForItemAtIndexPath:
就会调用它。
难道是我的自定义布局子类中的某些代码阻止cellForItemAtIndexPath
被调用?