2015-09-21 10 views
15

私は次のことを試してみた:方法のUIWebView iOS9のための完全に無効に虫眼鏡へ

html, body, div, p, a, table, img 
{ 
-webkit-user-select: none !important; 
user-select: none !important; 
-webkit-user-callout: none !important; 
-webkit-touch-callout: none !important; 
} 

これは、画面全体を占める私のUIWebViewのために働くのではなく、私のUIWebView(上記adbannerview)のために、 uiwebviewの上にある虫眼鏡をadbannerviewに押し付けます。

このanswerに示唆されているように、uiwebviewのサブビューでUILongPressGestureRecognizersを無効にすることを含むものがありますか?

+0

@rmaddy、私の質問をお読みください。それはその質問の重複ではありません。私は彼らの解決策を試してきたし、自分の解決策を私の質問に入れ、それが何をしているのかを説明しました。 – mark

+0

ありがとう@rmaddy。 – mark

+1

ここで問題はありますか? –

答えて

6

各ページが読み込まれた後にジェスチャーが無効になるようにすることで、提案されたコメントが機能するようになりました。あなたのWebViewのデリゲートでそう

、:

func webViewDidFinishLoad(webView: UIWebView) { 
    disableLongPressGesturesForView(webView) 
} 

次に、あなたの関数は(と、それはサブビュー子供)のWebViewの各サブビューを検索し、任意の長押しジェスチャーを無効にすることができます。

func disableLongPressGesturesForView(view: UIView) { 
    for subview in view.subviews { 
     if let gestures = subview.gestureRecognizers as [UIGestureRecognizer]! { 
      for gesture in gestures { 
       if gesture is UILongPressGestureRecognizer { 
        gesture.enabled = false 
       } 
      } 
     } 
     disableLongPressGesturesForView(subview) 
    } 
} 
+0

素晴らしい! Thx男:)素敵なコード!!! @rossbeale –

+0

ここで私の質問を見ることができますplz @rossbeale? :http://stackoverflow.com/questions/32761868/how-can-we-disable-the-effect-of-enabled-bold-text-from-settings-in-the-iphone/32762352?noredirect=1#comment53389075_32762352 –

2

私はUILongPressGestureRegonizerはその後、ここでそれを

を無効にしているのWebViewと発見からサブビューを繰り返すことで虫眼鏡を無効にしてはスニペットです:

- (void)disableWebViewLongPressGestures:(UIWebView *)webview { 
    for(id subView in webview.subviews) { 
     if([subView isKindOfClass:[UIScrollView class]]) { 
      UIScrollView *scrollView = (UIScrollView *)subView; 
      for(id ssView in scrollView.subviews) { 
       if([NSStringFromClass([ssView class]) isEqualToString:@"UIWebBrowserView"]) { 
        for(UIGestureRecognizer *gs in [ssView gestureRecognizers]) { 
         if ([gs isKindOfClass:[UILongPressGestureRecognizer class]]) 
         { 
          gs.enabled = NO; 
         } 
        } 
       } 
      } 
     } 
    } 
} 
関連する問題