ios - UIScrollView View 弹回并且不会停留在底部

标签 ios ios7 uiview uiscrollview

我有这套:

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/

相关文章:

ios - 在 swift 中关闭模态 viewController 时传递数据

ios - 无法将 NSString 转换为 NSURL

ios - 将 Parse 对象添加到 NSMutableArray 中的方法是什么?

ios - 根据 Sprite 的当前位置让 Sprite 移动到某个位置?

ios - subview 的位置不是我所期望的

ios - iPhone:如何使用 Xcode 向 Web 服务发送 HTTP 请求

ios - TableView :performAction:forRowAtIndexPath:withSender delegates show warning

iphone - 通过AudioQueueStart功能在iOS7中进行录音

ios - 使用 ReactiveCocoa 进行 View 之间的通信?

ios- ScrollView 中的所有页面未加载自定义uiview