添加UIGestureRecognizer以在UIScrollView中查看

时间:2016-12-21 19:00:33

标签: uiscrollview uigesturerecognizer

 UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(textTapped:)];
    tap.delegate = self;
    tap.numberOfTapsRequired = 1;
    tap.cancelsTouchesInView = NO;

    for(PaginationView* page in self.flashView._innerScrollView.subviews) {
        [page addGestureRecognizer:tap];
    }

我有一个名为PaginationView的自定义视图,我在UIScrollView中有几个。

我想为每个人添加一个手势识别器。 它似乎将手势识别器添加到PaginationViews中,但是" textTapped"方法永远不会被调用。

我的委托实现了这个方法:

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

这是在我的PaginationView init方法中设置的:

self.userInteractionEnabled = YES;

谢谢!

0 个答案:

没有答案