UIWebView 使用手势UITapGestureRecogniz

UIGestureRecognizerDelegate
 

    /*去除上啦效果*/

    for (id subview in Webview.subviews)

    {

        if ([[subview classisSubclassOfClass: [UIScrollView class]])

        {

            ((UIScrollView *)subview).bounces = NO;

        }

    }

    //iOS 5之后的版本

    Webview.scrollView.bounces = NO;

 

    UITapGestureRecognizer* singleTap = [[UITapGestureRecognizer allocinitWithTarget:self action:@selector(OnclikeWeb:)];

    singleTap.delegateself;

    singleTap.cancelsTouchesInView = NO;

    

    [Webview addGestureRecognizer:singleTap];

//必须实现 否则无法触发点击事件

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

    return YES;

}

//必须实现

-(void)OnclikeWeb:(UITapGestureRecognizer *)tap

{

    [self Hidekey:nil];

 

}


from:https://blog.csdn.net/wsk_123_123/article/details/18703465

你可能感兴趣的:(iOS)