在视图控制器中嵌入UIScrollView并且不分页
问题描述:
我想在UIViewController内嵌入一个UIScrollView。我想滚动和分页启用。我有:在视图控制器中嵌入UIScrollView并且不分页
CGRect thirdRect=CGRectMake(0.0f, 50.0f, 200.0f, 200.0f);
self.myVC=[[UIScrollView alloc] initWithFrame:thirdRect];
self.myVC.pagingEnabled=YES;
self.myVC.scrollEnabled=YES;
//[self.myVC setBackgroundColor:[UIColor orangeColor]];
UIImage *myImage=[UIImage imageNamed:@"stina.jpg"];
UIImageView *jtImageView=[[UIImageView alloc] initWithImage:myImage];
[self.myVC addSubview:jtImageView];
[self.view addSubview:self.myVC];
这里是截图(无分页,滚动):
但没有滚动/分页。有什么我做错了吗?这甚至有可能吗?
THX提前
答
为了您的UIScrollView您应该设置内容的大小,然后滚动将开始发生
self.myVC.contentSize = CGSizeMake(1000,1000);
试试看
不错,这部分工作。分页完全是一个不同的话题? – timpone
Nop,你只需要启用分页和滚动应该分页,页面的大小是相同的框架。但是,您需要实现一个不同的屏幕控制,以显示当前页面,称为UIPageControl – perrohunter
thx,因流感而下降,因此忘记接受 – timpone