我有这套:
UIScrollView *scroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 1000.0)];
scroll.backgroundColor = [UIColor clearColor];
scroll.contentSize = CGSizeMake(320.0, 1000.0);
[self.view addSubview:scroll];
UIView *pView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 100.0, 300.0, 400.0)];
pView.backgroundColor = [UIColor whiteColor];
pView.layer.cornerRadius = 2.0;
pView.layer.borderColor = [UIColor blueColor].CGColor;
pView.layer.borderWidth = 1.0f;
[scroll addSubview:pView];
UIView *aView = [[UIView alloc] initWithFrame:CGRectMake(10.0, 500.0, 300.0, 20.0)];
aView.backgroundColor = [UIColor redColor];
[scroll addSubview:aView];
但每次我向下 ScrollView 时,屏幕都会弹回顶部。为什么?
最佳答案
不要将 ScrollView 的高度设置为大于屏幕尺寸 - 滚动的不是 ScrollView ,而是 ScrollView 中的内容。
关于ios - UIScrollView View 弹回并且不会停留在底部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25074998/