У меня есть требование для прокрутки изображений по горизонтали и по вертикали.Прокрутка по горизонтали и по вертикали в обоих направлениях
У меня есть разделы, которые будут segregated vertically
и in each section itself it will be so many images which will be scrolled horizontally
.
Я сделал вертикальную прокрутку, используя UICollectionView
с Ray wenderlich tutorial, но как получить горизонтальную прокрутку в каждом разделе?
Должен ли я использовать для этой цели любой другой объект, например UITableView
или UIScrollview
?
Доступно любое учебное пособие, как этого достичь?
Is it compulsory to implement Layout subclass or UICollectionviewFlowlayout when using collection view
?
EDIT
До сих пор я реализовал этот код, который прокручивает вертикально и имеет 5 разделов, каждый, но не в состоянии выделить отдельные секции
- (NSInteger)collectionView:(UICollectionView *)view numberOfItemsInSection:(NSInteger)section;
{
NSArray *arrayReturn = [self returnArray:section];
return arrayReturn.count;
}
- (NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView
{
return 5;
}
- (UICollectionViewCell *)collectionView:(UICollectionView *)cv cellForItemAtIndexPath:(NSIndexPath *)indexPath
{
ImageCell *cell = [cv dequeueReusableCellWithReuseIdentifier:@"imagecell" forIndexPath:indexPath];
NSBlockOperation *operation = [NSBlockOperation blockOperationWithBlock:^{
NSArray *arrSection = [NSArray arrayWithArray:[self returnArray:indexPath.section]];
NSString *fileName = [arrSection objectAtIndex:indexPath.row];
UIImage *image = [UIImage imageNamed:fileName];
dispatch_async(dispatch_get_main_queue(), ^{
// cell.imgVw.image = ;
if([CollectionView.indexPathsForVisibleItems containsObject:indexPath]){
ImageCell *currentCell = (ImageCell *) [cv cellForItemAtIndexPath:indexPath];
currentCell.imgVw.image = image;
}
});
}];
[self.thumbnailQueue addOperation:operation];
return cell;
}
- (UICollectionReusableView *)collectionView:(UICollectionView *)collectionView viewForSupplementaryElementOfKind:(NSString *)kind atIndexPath:(NSIndexPath *)indexPath
{
HeaderView *Header = [collectionView dequeueReusableSupplementaryViewOfKind:UICollectionElementKindSectionHeader withReuseIdentifier:@"PhotoHeaderView" forIndexPath:indexPath];
Header.lblHeaderTitle.text = @"Header title";
Header.backgroundColor = [UIColor yellowColor];
return Header;
}
Любой снимок экрана то, что именно объясняет ваше требование? –
все они основаны на ContentSize вашего ScrollView, так что пять соответствующих contentSize вашего ScrollView и дать блокировку направления UIScrollView. – iPatel