内部具有垂直UIScrollViews的水平UIScrollView - 如何在滚动外部水平视图时阻止滚动内部滚动视图? [英] Horizontal UIScrollView having vertical UIScrollViews inside - how to prevent scrolling of inner scroll views when scrolling outer horizontal view?

查看:104
本文介绍了内部具有垂直UIScrollViews的水平UIScrollView - 如何在滚动外部水平视图时阻止滚动内部滚动视图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

无法找到解决方案。

我正在构建一个具有大滚动视图的应用程序,具有分页(水平)。
在这个滚动视图中,有一个UIView的网格,每个都有一个UIScrollview,有垂直滚动视图。

I am building an app, with big scroll view, who has paging (Horizontal). Inside this scroll view, there is a grid of UIView's, and an UIScrollview inside each one of them, with vertical scroll view.

现在,重点是当我分页我的'大'滚动视图时,有时触摸卡在网格的UIViews内的一个小滚动视图中。

Now, the point is, When I'm paging my 'big' scrollview, sometimes the touch get stuck in one of small scrollviews inside the UIViews of the grid.

我不知道如何避免它 - 尝试使用hitTest但仍无法找到答案。

I don't know how to avoid it - tried trick with hitTest but still couldn't find the answer.

希望我很清楚...

感谢您的帮助。

编辑:

这是更大的scrollview:

This is the bigger scrollview:

@implementation UIGridScrollView
- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    self.pagingEnabled;
    return self;
}
@end

现在,对于这个UIGridScroll视图,我添加了子视图这个视图:

Now, to this UIGridScroll View, I added as a subview this view:

@implementation UINoteView
{
IBOutlet UIScrollView *_innerScrollView; // this scrollview frame is in the size of the all UINoteView
}

- (void)awakeFromNib
{
    _innerScrollView.contentSize = CGSizeMake(_innerScrollView.frame.size.width, _innerScrollView.frame.size.height+50.0f);
}
@end

分页工作正常,内部滚动视图有效好吧,但是当我分页更大的音符视图时,我的手指'卡在'_innerScrollView中的次数太多了。

The paging works well, the inner scroll view works well, but too many times when I paging the bigger note view, my finger 'get stuck' in the _innerScrollView.

谢谢!

推荐答案

@stanislaw,我刚试过你在iPhone设备上建议的解决方案。

@stanislaw, I've just tried the solution you suggest on an iPhone device.

我看到你的问题。

你的代码确实阻止了偶尔的垂直视图滚动,但我相信它不是同时手势识别完成工作 - 注释您为内部视图提供的整个代码,并使用外部滚动视图的代码进行以下修改:

Your code does prevent occasional scrolls of vertical views but I believe it is not the simultaneous gesture recognition does the job - comment the entire code you provide for inner views and use the code for the outer scroll view with the following modification:

@interface OuterHorizontalScrollView : UIScrollView ...
@property (weak) InnerVerticalScrollView *currentActiveView; // Current inner vertical scroll view displayed.
@end

@implementation OuterHorizontalScrollView
- (BOOL)gestureRecognizerShouldBegin:(UIGestureRecognizer *)gestureRecognizer {
    if (self.currentActiveView.dragging == NO) {
        self.currentActiveView.scrollEnabled = NO; // The presence of this line does the job
    }
    return YES;
}

- (void)scrollViewDidEndDragging:(PlacesScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    self.currentActiveView.scrollEnabled = YES; // This is very likely should be done for all subviews, not only a current.
}    
@end

这篇关于内部具有垂直UIScrollViews的水平UIScrollView - 如何在滚动外部水平视图时阻止滚动内部滚动视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆