kyo*_*010 4 iphone paging uiscrollview
我现在正在制作数字漫画.我的应用程序在没有缩放时有水平分页.但是在缩放时,图片的高度超过了屏幕高度.所以应用程序有垂直分页.
但我不需要垂直分页.我想在zooiming期间进行水平分页而不进行垂直分页.
请教我.
Eph*_*aim 13
这很简单.正如你的朋友建议的那样,你至少需要两个UIScrollView.您将需要一个UIScrollView用于水平(即分页),您将需要一个UIScrollView针对每个页面.关键点是(让我们命名scrollHorizontal和scrollVertical):
scrollHorizontal.frame.height必须相等scrollHorizontal.contentSize.height(否则,你将最终得到垂直分页)scrollVertical:首先,每个页面都有一个.框架宽度contentSize.width应与页面宽度(在您的scrollHorizontal)中匹配并有意义.你当然应该有框架高度不超过scrollHorizontal.contentSize.height.示例代码:
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.
| 归档时间: |
|
| 查看次数: |
9557 次 |
| 最近记录: |