将手势转发到UITableViews

时间:2016-04-29 08:41:40

标签: ios objective-c uitableview uipangesturerecognizer uitouch

我的故事板里有一个带有两个UITableViewControllers(master& detail)的UISplitViewController-Subclass。

我的BOSplitViewController通过子视图进行扩展以进行绘制。

_linienView = [[BODrawLinienView alloc] initWithFrame:self.view.bounds];

[self.view addSubview:_linienView];

在BODrawLinienView中,我实现了我的UIPanGestureRecognizer来绘制UIBezierPaths。

    _panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(recognizedGesture:)];
    _panRecognizer.minimumNumberOfTouches = 1;
    _panRecognizer.maximumNumberOfTouches = 1;
    _panRecognizer.delegate = self;
    _panRecognizer.cancelsTouchesInView = NO;

    [self addGestureRecognizer:_panRecognizer];

UIGesturerecognizerDelegate方法也在那里实现。

#pragma mark - <UIGestureRecognizerDelegate>

- (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)panGestureRecognizer {

    CGPoint velocity = [panGestureRecognizer velocityInView:self];

    return fabs(velocity.y) < fabs(velocity.x); // < >
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer {

    return YES;
}

gestureRecognizerShouldBegin:中的速度检查允许我避免识别器处理的垂直事件,识别器只应接受更多或更少的水平事件。

但是,此检查所避免的所有事件都不会转发到SplitViewControlles ViewControllers中的UITableViews。

编辑:我已在my Dropbox directory

上准备了此行为的演示项目

有人知道如何实现向这些视图转发事件吗?

0 个答案:

没有答案