开发者

Hide navigationBar and toolbar in view using UIGestureRecognizer, which contains UIWebView and UIImage

I'm creating a UIViewController with UIImageView, 2xUIWebView.

Hide navigationBar and toolbar in view using UIGestureRecognizer, which contains UIWebView and UIImage

I'm trying to hide UINavigationBar and UIToolB开发者_StackOverflow社区ar with UITapGestureRecognizer, It's no problem, but when i added in ViewController UIWebView it stop works. In "UIWebView youtube player" - I Have code which plays video from youtube. When I'm touching in "white area" or UIImageView- gesture recognizer works, but when I'm touching UIWebView - nothing happens. Help me please fix it. Thank you


If you are add gesture recognizer to the parent view than you are doing it wrong. You should attach it to the webView instead.

[self.webView addGestureRecognizer:singleFingerTap];

instead of

[self.view addGestureRecognizer:singleFingerTap];


UIWebView consists of some subviews, and the subviews have already add some gesture recognizers, so if you just add gesture recognizer to UIWebView, it will not be processed, because the deeper UIView in the view tree will handle the gesture first. To allow both the new added gesture recognizer and the built-in gesture recognizer processed simultaneously, you should adopt the UIGestureRecognizerDelegate protocol to allow this.

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

yourTapRecognizer.delegate = self; //add this line with you UIGestureRecognizer alloc/init

for some detail information see this blog: How to Add Custom Process to UIWebview Tap Gestures

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜