With XCode 4.6 building for iOS 6.1, I'm using a UICollectionView
from a storyboard, and I thought that the class implemented scrolling by default. I have made a simple test app with a storyboard that has just a Collection View and one Collection View Cell, and code that implements just collectionView:cellForItemAtIndexPath:
and collectionView:numberOfItemsInSection:
, calling for enough cells so that scrolling is required to see all the cells.
I thought that with nothing else, I would be able to scroll vertically within the UICollectionView
. It shows the visible cells but doesn't scroll. What am I missing here?
Why wouldn't this component allow me to scroll vertically, what am I unable to see?
The implementation code is about as simple as possible:
//
// TestpViewController.h
//
#import <UIKit/UIKit.h>
@interface TestpViewController : UIViewController <UICollectionViewDataSource, UICollectionViewDelegate>
@end
//
// TestpViewController.m
//
#import "TestpViewController.h"
@interface TestpViewController ()
@property (weak, nonatomic) IBOutlet UICollectionView *collectionView;
@end
@implementation TestpViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (NSInteger)collectionView:(UICollectionView *)collectionView
numberOfItemsInSection:(NSInteger)section
{
return 30;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView
cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
UICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"testCell" forIndexPath:indexPath];
return cell;
}
@end