处理视图上的多个手势

时间:2012-08-23 14:03:07

标签: objective-c ios5 uiwebview uibutton uigesturerecognizer

有没有办法在UIWebView上检测单击与滚动手势?

我有一个UIWebView,它包含很多次的富文本,滚动,如果有很多文本内容。我需要添加一个新功能,允许用户点击UIWebView来获取不同的内容。

问题是,我的解决方案是在UIWebView上放置一个清晰的自定义按钮,该按钮处理点击但杀死滚动功能。凉爽的孩子们如何做这类事情?

谢谢

enter image description here

1 个答案:

答案 0 :(得分:0)

我用手势识别器解决了这个问题。这完全消除了对UIButton叠加的需要。

    //Handle taps on the UIWebView
    self.singleTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(**tapDetected:**)];
    singleTap.numberOfTapsRequired = 1;
    singleTap.delegate = self;
    [self.readAboutItView addGestureRecognizer:singleTap];

   //Set up the event handler
- (IBAction)**tapDetected:**(UIGestureRecognizer *)sender {

   //Do something with the content
   [self webViewTouched:self];

}

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch{


    return YES;

}

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


    return YES;


}