将触摸传递给另一个视图

时间:2014-05-14 01:07:42

标签: ios uitableview uiscrollview uigesturerecognizer

我在另一个UIScrollView中有一个UIScrollView作为子视图我试图阻止子视图中的滚动并将触摸传递给超级视图。

- (void)viewDidLoad
{
    self.outerScrollView = [[UIScrollView alloc] initWithFrame:self.view.bounds];
    self.outerScrollView.showsVerticalScrollIndicator = NO;

    self.gestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)];
    self.gestureRecognizer.delegate = self;
    [self.tableViewController.tableView addGestureRecognizer:self.gestureRecognizer];
    [self.outerScrollView addSubview:self.tableViewController.tableView];
    [self.view addSubview:self.outerScrollView];
}

- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer
{
    return YES;
}


- (void)handlePanGesture:(UIPanGestureRecognizer *)gesture
{


    if (gesture.state == UIGestureRecognizerStateBegan) {
        if (gesture.view == self.tableViewController.tableView) {
            self.tableViewController.tableView.contentOffset = CGPointMake(0, 0);
            // Pass to self.outerScrollView
            // Trying to make self.outerScrollView take over the touch 
        }
    }
}

0 个答案:

没有答案