Вот мой подкласс UICollectionViewFlowLayout:
@implementation MyCollectionViewFlowLayout
- (id)init
{
self = [super init];
if (self) {
[self setup];
}
return self;
}
- (void)setup
{
self.itemSize = CGSizeMake(320, 320);
self.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
self.minimumInteritemSpacing = 0;
self.minimumLineSpacing = 0;
self.scrollDirection = UICollectionViewScrollDirectionVertical;
}
- (void)prepareLayout {
[super prepareLayout];
}
- (CGSize)collectionViewContentSize {
return self.itemSize;
}
- (NSArray *)layoutAttributesForElementsInRect:(CGRect)rect {
NSArray* allAttributesInRect = [super layoutAttributesForElementsInRect:rect];
return allAttributesInRect;
}
- (UICollectionViewLayoutAttributes*)layoutAttributesForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewLayoutAttributes* attributes = [super layoutAttributesForItemAtIndexPath:indexPath];
return attributes;
}
@end
Когда я делаю следующее, представление коллекции не будет прокручиваться:
MyCollectionViewFlowLayout* flowLayout = [[MyCollectionViewFlowLayout alloc] init];
Однако, если я сделаю это:
UICollectionViewFlowLayout* flowLayout = [[UICollectionViewFlowLayout alloc] init];
flowLayout.itemSize = CGSizeMake(320, 320);
flowLayout.sectionInset = UIEdgeInsetsMake(0, 0, 0, 0);
flowLayout.minimumInteritemSpacing = 0;
flowLayout.minimumLineSpacing = 0;
flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;
Затем представление коллекции прокручивается нормально. Что я делаю неправильно в подклассе UICollectionViewFlowLayout?