Reputation: 169
I don't have code as I don't know how to begin with.
Any suggestions?
Upvotes: 0
Views: 5547
Reputation: 104
If want one item why you don`t try UItableView
UITableView *myTableView = [UITableView alloc] init];
Delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
Upvotes: -1
Reputation: 4040
As of Apples WWDC Video concerning UICollectionViews
you should create a custom UICollectionViewFlowLayout
.
As said there you should set the bottom and top Edge Insets of the CollectionView so that only one Cell will fit in between and the rest will be done by the CollectionView.
The Edge Insets can be done with UIEdgeInsetsMake(top, left, bottom, right)
So, in your Layout you can customize the init
like this:
-(id)init
{
self = [super init];
if (self) {
self.itemSize = CGSizeMake(100, 100);
self.scrollDirection = UICollectionViewScrollDirectionHorizontal;
CGRect bounds = [[UIScreen mainScreen] bounds];
CGFloat spacing = bounds.size.height / 2 - self.itemSize.height / 2;
self.sectionInset = UIEdgeInsetsMake(spacing, 0, spacing, 0);
}
return self;
}
So that, in fact you make the height of the CollectionView the height of the Screen minus the height of a cell, except that it's centered.
Hope that helps.
Upvotes: 2