【发布时间】:2013-06-06 06:15:48
【问题描述】:
我需要水平和垂直滚动图像。
我的部分将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?
编辑
到目前为止,我已经实现了这个垂直滚动的代码,每个部分有 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;
}
【问题讨论】:
-
任何能准确解释您的要求的屏幕截图?
-
它都是基于你的ScrollView的ContentSize,所以你的ScrollView有五个合适的contentSize并且给UIScrollView的方向锁。
标签: iphone ios objective-c uiscrollview uicollectionview