C'est vraiment simple. Comme votre ami l'a suggéré, vous aurez besoin d'AU MOINS deux UIScrollView
. Vous aurez besoin d'un UIScrollView
pour l'horizontale (c'est-à-dire pagination), et vous aurez besoin d'un UIScrollView
pour chaque page. Les points clés sont (nous allons les nommer scrollHorizontal
et scrollVertical
):
scrollHorizontal.frame.height
doit être égal scrollHorizontal.contentSize.height
(sinon, vous finirez avec pagination verticale)
scrollVertical
: d'abord, vous aurez un de cela pour chaque page . La largeur du cadre et contentSize.width
doit correspondre et donner un sens à la règle. la largeur d'une page (dans votre scrollHorizontal
). Vous devriez bien sûr avoir la hauteur du cadre ne dépasse pas scrollHorizontal.contentSize.height
.
Exemple de code:
UIScrollView scrollHorizontal = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
scrollHorizontal.pagingEnabled = YES;
scrollHorizontal.directionalLockEnabled = YES; // not needed but helpful
// Now let's create each page
UIScrollView *scrollPage1 = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
[scrollPage1 addSubview:theContentViewForPage1];
scrollPage1.contentSize = CGSizeMake(self.view.bounds.size.width, theContentViewForPage1.bounds.size.height);
// Add page to scrollHorizontal
[scrollHorizontal addSubview:scrollPage1];
[scrollPage1 release];
//...add more pages (REMEMBER to set the scroll view's frame.origin.x accordingly for each additional page)
// Set the scrollHoriztonal content size
scrollView.contentSize = CGSizeMake(self.view.bounds.size.width*NUMBER_OF_PAGES, self.view.bounds.size.height);
// Now add the scrollview to self.view; or even self.view = scrollHorizontal, etc.
peut être fait avec une vue de défilement: http://stackoverflow.com/questions/10478586/uiscrollview-paging-in-single-direction/10480071#10480071 –