jeudi 29 janvier 2015

iOS Horizontal CollectionView not scrolling all the way

I have a single row collectionview that scrolls horizontally. The collectionview works but it cuts off the second to last cell (labeled orange) and hides the last cell.



I have 5 cells, each of size 166x166. I have checked the contentsize of the viewlayout and it's width is 830 which is correct, yet I am unable to scroll that far.


Here is the settings in Storyboard:


enter image description here


And here is the code for the collectionview.



#pragma mark Collection View Methods

-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView {
return 1;
}

-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section {
return [array count];
}

-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath {
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"FeaturedCell" forIndexPath:indexPath];

UILabel *label = (UILabel *) [cell viewWithTag: 100];
label.text = [array objectAtIndex:indexPath.row];

[cell.layer setBorderWidth:2.0f];
[cell.layer setBorderColor:[UIColor whiteColor].CGColor];

return cell;
}



Aucun commentaire:

Enregistrer un commentaire