我在屏幕上有一个UIScrollView(A)父级,在其内容中我有两个控件 - 顶部的另一个UIScrollView(B)和底部的UIView(C),
A是全屏(460px) B 460px但内容比屏幕(600px)长,所以它在里面滚动 C 460px固定 也启用了分页,因此B是第1页,C是第2页,
当我向下平移时B滚动并且当它到达底部时它反弹而不是拉动视图C,如果我将反弹设置为NO然后它被卡在底部并且只有当我抬起手指并再次平移时它才会拉动查看C ..
我看到了一些相关的问题,但没有他们帮助我(How to steal touches from 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)];}
由于