我在屏幕上有一个 UIScrollView (A) 父级,在它的内容里面我有两个控件 - 顶部的另一个 UIScrollView (B) 和底部的 UIView (C),
A 是全屏(460 像素) B 460 像素,但内容比屏幕(600 像素)长,所以它在 C 460 像素内滚动固定也启用了分页,所以 B 是第一页,C 是第二页,
当我向下平移时,B 正在滚动,当它到达底部时,它会反弹而不是拉视图 C,如果我将反弹设置为 NO,那么它就会卡在底部,只有当我抬起手指并再次平移时,它才会拉视图 C。 .
我看到了一些相关的问题,但没有一个对我有帮助(如何从 UIScrollView 窃取触摸?)
重新创建情况的代码示例(或从我的保管箱下载https://www.dropbox.com/s/f9j0vkg902214ab/Test2.zip)
- (void)viewDidLoad{
[super viewDidLoad];
// create main scroll
UIScrollView *scrollA = [[UIScrollView alloc] initWithFrame:self.view.frame];
scrollA.pagingEnabled = YES;
scrollA.bounces = YES;
[self.view addSubview:scrollA];
// create top scroll B
UIScrollView *scrollB = [[UIScrollView alloc] initWithFrame:self.view.frame];
scrollB.backgroundColor = [UIColor greenColor];
scrollB.bounces = YES;
[scrollA addSubview:scrollB];
// create something to put in B
CGRect frameViewB = scrollB.frame;
frameViewB.origin.x = 30;
frameViewB.size.width = 260;
frameViewB.size.height = 600;
UIView *viewInsideB = [[UIView alloc] initWithFrame:frameViewB];
viewInsideB.backgroundColor = [UIColor blueColor];
[scrollB addSubview:viewInsideB];
[scrollB setContentSize:viewInsideB.frame.size];
// create bottom view
CGRect frameC = self.view.frame;
frameC.origin.y = 460;
UIView *viewC = [[UIView alloc] initWithFrame:frameC];
viewC.backgroundColor = [UIColor yellowColor];
[scrollA addSubview:viewC];
// set content for 2 pages
[scrollA setContentSize:CGSizeMake(320, 920)];}
谢谢