[英]Disable horizontal scroll in a subview of UIScrollView
I have 3 UIScrollViews
, call them A
, B
, and C
. 我有3个
UIScrollViews
,分别称为A
, B
和C
A
is a Paging scrollview, that has many B
scrollviews added as subviews (the pages). A
是一个分页滚动视图,其中添加了许多B
滚动视图作为子视图(页面)。 B
only scrolls vertically. B
仅垂直滚动。 C
is a scrollview added as a subview to a UIView
that is added as a subview to B
. C
是作为子视图添加到UIView
的滚动视图,而UIView
是作为B
子视图添加的。
The functionality I am trying to achieve is: 我想要实现的功能是:
Disallow paging of A
if a horizontal scroll is happening within the UIView
that is housing C
. 如果在容纳
C
的UIView
中发生水平滚动,则不允许分页A
However, still allow the vertically scrolling of B
. 但是,仍然允许
B
的垂直滚动。
Implement the - (void)scrollViewDidScroll:(UIScrollView*)scrollView
to find out which scrollview is scrolling and then check contentOffset
property of scrollview to determine the scrolling position of scrollviews. 实现
- (void)scrollViewDidScroll:(UIScrollView*)scrollView
可以找出正在滚动的滚动视图,然后检查scrollview的contentOffset
属性以确定滚动视图的滚动位置。 scrollViewDidEndDecelerating
delegate can be used to detect the end of scrolling. scrollViewDidEndDecelerating
委托可用于检测滚动结束。
for eg:- 例如:
- (void)scrollViewDidScroll:(UIScrollView*)scrollView {
if (scrollView == C) {
//disable scrolling of A
}
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView {
if (scrollView == C) {
//enable scrolling of A
}
}
Based on your exact requirement, you can use these two delegates and contentOffset
of that particular scrollview to get the desired effect. 根据您的确切要求,可以使用这两个委托和该特定scrollview的
contentOffset
来获得所需的效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.