Due to some goals (e.g. pull to refresh) I need the UICollectionView to bounce or scroll when there are no cells - means numberOfItemsInSection: return 0
I have my code:
... UICollectionViewFlowLayout *flowLayout =[[UICollectionViewFlowLayout alloc] init]; flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical; flowLayout.minimumInteritemSpacing = SPLIT_SPACE; flowLayout.minimumLineSpacing = SPLIT_SPACE; targetCollection = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height - TABBAR_HEIGHT) collectionViewLayout:flowLayout]; [targetCollection registerNib:[UINib nibWithNibName:@"DashboardCell" bundle:[NSBundle mainBundle]] forCellWithReuseIdentifier:@"DashboardCell"]; targetCollection.autoresizingMask = UIViewAutoresizingFlexibleHeight; targetCollection.backgroundColor = [UIColor colorWithHex:@"#EAEAEA"]; targetCollection.contentInset = UIEdgeInsetsMake(0, 0, 20, 0); targetCollection.alwaysBounceVertical = YES; ... #pragma mark - UICollectionViewDataSource - (NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section; { return 0; }
However, when testing this empty UICollectionView cannot bounce and scroll. I suspect this is due to an empty cell, but I need to enable bounce or scroll when there is no cell. This seems like another problem: SVPullToRefresh cannot pull an empty UICollectionView
source share