1

画像を水平および垂直にスクロールする必要があります。

と のセクションがsegregated verticallyありin each section itself it will be so many images which will be scrolled horizontallyます。

Ray wenderlich チュートリアルUICollectionViewを使用して垂直スクロールを作成しましたが、各セクションで水平スクロールを取得するにはどうすればよいですか?

この目的のために、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;
}
4

2 に答える 2

1

同様のチュートリアルを次に示します。

http://www.raywenderlich.com/4723/how-to-make-an-interface-with-horizo​​ntal-tables-like-the-pulse-news-app-part-2

基本的に、次のことを行う必要があります。

  • tableView または CollectionView を取る
  • 各セルに、水平スクロールを有効にしたスクロールビューを追加する必要があります。
  • セルの作成中に各セルのスクロール ビューにアイテムを追加し、スクロール ビューに適切なコンテンツ サイズを与えます。

望ましい結果が得られます。

于 2013-06-06T06:25:24.733 に答える
0

これを試して

**viewController.h**

IBOutlet UIScrollView *scrollViewMain;


**viewController.m**

- (void)viewDidLoad
{
   [super viewDidLoad];
   [self createDisplay];
// Do any additional setup after loading the view, typically from a nib.
}

-(void) createDisplay
{
for(UIView *subView in scrollViewMain.subviews)
{
    if(![subView isKindOfClass:[UIImageView class]])
    {
        [subView removeFromSuperview];
    }
}
int yPos =5;

for (int i=0; i< 10; i++)
{

    int xPosition=5;


    UIScrollView *scrollView =[[UIScrollView alloc]initWithFrame:CGRectMake(xPosition, yPos, scrollViewMain.frame.size.width, 100)];
    scrollView.backgroundColor =[UIColor clearColor];
    scrollView.autoresizingMask =UIViewAutoresizingFlexibleWidth;



    xPosition +=5;

    for (int j=0; j<10; j++)
    {

        UILabel *lblTitle = [[UILabel alloc] initWithFrame:CGRectMake(xPosition, 0, 100, 100)];
        lblTitle.textColor = [UIColor whiteColor];
        lblTitle.backgroundColor =[UIColor greenColor];
        lblTitle.text = @"test";
        lblTitle.numberOfLines =0;
        lblTitle.font = [UIFont boldSystemFontOfSize:15];

        [scrollView addSubview:lblTitle];

        xPosition +=100;
        xPosition +=10;
    }
    [scrollView setContentSize:CGSizeMake(xPosition, 100)];
    [scrollViewMain addSubview:scrollView];
    yPos +=120;
}
[scrollViewMain flashScrollIndicators];
[scrollViewMain setContentSize:CGSizeMake(0, yPos)];
  }
于 2013-06-06T08:15:45.287 に答える