我有一个视图,UIPanGestureRecognizer可以垂直拖动视图.所以在识别器回调中,我只更新y坐标来移动它.这个视图的超级视图有一个UIPanGestureRecognizer水平拖动视图,只是更新x坐标.
问题是第一个UIPanGestureRecognizer是事件是垂直移动视图,所以我不能使用超视图手势.
我试过了
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer
shouldRecognizeSimultaneouslyWithGestureRecognizer:
(UIGestureRecognizer *)otherGestureRecognizer;
Run Code Online (Sandbox Code Playgroud)
两者都会奏效,但我不希望如此.我希望只有在运动明显水平的情况下才能检测水平.所以如果UIPanGestureRecognizer有一个方向属性会很棒.
我怎样才能实现这种行为?我发现文档很混乱,所以也许有人可以在这里更好地解释它.
无法找到解决方案.
我正在构建一个具有大滚动视图的应用程序,具有分页(水平).在这个滚动视图中,有一个UIView网格,每个网格中都有一个UIScrollview,有垂直滚动视图.
现在,关键是,当我分页我的'大'滚动视图时,有时触摸会卡在网格的UIViews中的一个小滚动视图中.
我不知道如何避免它 - 尝试使用hitTest但仍然无法找到答案.
希望我很清楚......
谢谢你的帮助.
编辑:
这是更大的scrollview:
@implementation UIGridScrollView
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
self.pagingEnabled;
return self;
}
@end
Run Code Online (Sandbox Code Playgroud)
现在,对于这个UIGridScroll 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
Run Code Online (Sandbox Code Playgroud)
分页效果很好,内部滚动视图效果很好,但是当我分页较大的音符视图时,我的手指"卡在"_innerScrollView中的次数太多了.
谢谢!