我只想滚动一页然后再滚动到另一页。
我设置m_pScrollView.pagingEnabled = YES
和m_pScrollView.bounces = NO
但是当我滚动到页面边缘时,它会退出页面范围然后返回,就像惯性效果一样。
我只是希望scoll只有一页而不是更多。任何人都可以帮助我吗?
- (void)viewDidLoad {
[super viewDidLoad];
m_pScrollView = [[UIScrollView alloc]initWithFrame:CGRectMake(0, 0, 768, 1024)];
m_pScrollView.delegate = self;
m_pScrollView.contentSize = CGSizeMake(768 * 3, 1024);
m_pScrollView.pagingEnabled = YES;
m_pScrollView.bounces = NO;
m_pScrollView.alwaysBounceHorizontal = NO;
m_pScrollView.alwaysBounceVertical = NO;
Myview *myview = [[Myview alloc]initWithFrame:CGRectMake(0, 0, 768, 1024)];
myview.backgroundColor = [UIColor redColor];
Myview *myview2 = [[Myview alloc]initWithFrame:CGRectMake(768, 0, 768, 1024)];
myview2.backgroundColor = [UIColor blueColor];
Myview *myview3 = [[Myview alloc]initWithFrame:CGRectMake(768 * 2, 0, 768, 1024)];
myview3.backgroundColor = [UIColor grayColor];
[m_pScrollView addSubview:myview];
[m_pScrollView addSubview:myview2];
[m_pScrollView addSubview:myview3];
[self.view addSubview:m_pScrollView];
}
答案 0 :(得分:0)
您必须像这样设置内容大小
m_pScrollView.contentSize = CGSizeMake(x,y);
的更多信息