UIScrollView水平分页

时间:2011-09-09 06:42:02

标签: iphone uiscrollview

我想创建一个具有水平分页视图的iphone应用程序。我已经在网上看到了许多水平分页的例子,但我还没有看到每个页面都有垂直滚动的例子。换句话说,我希望有一个水平分页,每个页面都会垂直滚动(向上和向下)。谢谢你的帮助!

凯文

1 个答案:

答案 0 :(得分:0)

基本上,您需要设置2个属性才能分页滚动视图:

/* set the frame of the scrollView */
[scrollView setFrame:CGRectMake(0,0,280,340)];

/* make sure the scrollView snaps (pages) */
[scrollView setPagingEnabled:YES];

/* this tells you the size of the content, width, height */
[scrollView setContentSize:CGSizeMake(280, 680)];

280是宽度 680是高度,您将获取滚动视图的原始高度(这里 340 并将其乘以您想要的页数。因此,在此示例中,将有2个垂直页面。 2因为340 x 2是680,有意义吗?

同样的方法适用于水平分页,只有你将乘以scrollView的宽度。