<small id='Ax7ce'></small><noframes id='Ax7ce'>

        <legend id='Ax7ce'><style id='Ax7ce'><dir id='Ax7ce'><q id='Ax7ce'></q></dir></style></legend>

          <bdo id='Ax7ce'></bdo><ul id='Ax7ce'></ul>
        <i id='Ax7ce'><tr id='Ax7ce'><dt id='Ax7ce'><q id='Ax7ce'><span id='Ax7ce'><b id='Ax7ce'><form id='Ax7ce'><ins id='Ax7ce'></ins><ul id='Ax7ce'></ul><sub id='Ax7ce'></sub></form><legend id='Ax7ce'></legend><bdo id='Ax7ce'><pre id='Ax7ce'><center id='Ax7ce'></center></pre></bdo></b><th id='Ax7ce'></th></span></q></dt></tr></i><div id='Ax7ce'><tfoot id='Ax7ce'></tfoot><dl id='Ax7ce'><fieldset id='Ax7ce'></fieldset></dl></div>
      1. <tfoot id='Ax7ce'></tfoot>

      2. 在 WKWebView 中隐藏键盘辅助栏

        时间:2023-10-21
        1. <i id='2g0hQ'><tr id='2g0hQ'><dt id='2g0hQ'><q id='2g0hQ'><span id='2g0hQ'><b id='2g0hQ'><form id='2g0hQ'><ins id='2g0hQ'></ins><ul id='2g0hQ'></ul><sub id='2g0hQ'></sub></form><legend id='2g0hQ'></legend><bdo id='2g0hQ'><pre id='2g0hQ'><center id='2g0hQ'></center></pre></bdo></b><th id='2g0hQ'></th></span></q></dt></tr></i><div id='2g0hQ'><tfoot id='2g0hQ'></tfoot><dl id='2g0hQ'><fieldset id='2g0hQ'></fieldset></dl></div>

          <small id='2g0hQ'></small><noframes id='2g0hQ'>

              <tbody id='2g0hQ'></tbody>

            <tfoot id='2g0hQ'></tfoot><legend id='2g0hQ'><style id='2g0hQ'><dir id='2g0hQ'><q id='2g0hQ'></q></dir></style></legend>
                • <bdo id='2g0hQ'></bdo><ul id='2g0hQ'></ul>

                • 本文介绍了在 WKWebView 中隐藏键盘辅助栏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  如何在 WKWebview 中隐藏键盘附件栏?虽然有一些 UIWebView 的资源,但我在 Stackoverflow 上找不到 WkWebview 的资源.

                  How can I hide keyboard accessory bar in WKWebview? Although there are some resources for UIWebView, I haven't been able to find one for WkWebview on Stackoverflow.

                  相关:

                  1. 删除 UIWebView 键盘上的配件
                  2. iOS 7 UIWebView 键盘问题

                  推荐答案

                  这可以在 WKWebView 中使用 在UIWebView上调出inputAccessoryView的方法.

                  This is possible in WKWebView with a variant of the method for swizzling out the inputAccessoryView on UIWebView.

                  首先,添加这个小类:

                  @interface _NoInputAccessoryView : NSObject
                  
                  @end
                  
                  @implementation _NoInputAccessoryView
                  
                  - (id)inputAccessoryView {
                      return nil;
                  }
                  
                  @end
                  

                  接下来,添加这个方法:

                  Next, add this method:

                  - (void)removeInputAccessoryViewFromWKWebView:(WKWebView *)webView {
                      UIView *targetView;
                  
                      for (UIView *view in webView.scrollView.subviews) {
                          if([[view.class description] hasPrefix:@"WKContent"]) {
                              targetView = view;
                          }
                      }
                  
                      if (!targetView) {
                          return;
                      }
                  
                      NSString *noInputAccessoryViewClassName = [NSString stringWithFormat:@"%@_NoInputAccessoryView", targetView.class.superclass];
                      Class newClass = NSClassFromString(noInputAccessoryViewClassName);
                  
                      if(newClass == nil) {
                          newClass = objc_allocateClassPair(targetView.class, [noInputAccessoryViewClassName cStringUsingEncoding:NSASCIIStringEncoding], 0);
                          if(!newClass) {
                              return;
                          }
                  
                          Method method = class_getInstanceMethod([_NoInputAccessoryView class], @selector(inputAccessoryView));
                  
                          class_addMethod(newClass, @selector(inputAccessoryView), method_getImplementation(method), method_getTypeEncoding(method));
                  
                          objc_registerClassPair(newClass);
                      }
                  
                      object_setClass(targetView, newClass);
                  }
                  

                  那么你所要做的就是调用那个方法并传入你的 WKWebView:

                  Then all you have to do is call that method and pass in your WKWebView:

                  [self removeInputAccessoryViewFromWKWebView:webView];
                  

                  注意:我还不确定这是否会通过应用审核,但它非常与我用于UIWebView的相同代码,并且确实如此通过审核.

                  Note: I do not yet know for sure if this will pass app review, but it is extremely similar to the same code I used for UIWebView, and that did pass review.

                  更新:此代码位于已通过 App Store 审核的应用中.

                  Update: This code is in an app that has passed App Store review.

                  这篇关于在 WKWebView 中隐藏键盘辅助栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:将 NSData 加载到 UIWebView 下一篇:Swift UIWebView 不加载 http 网站

                  相关文章

                        <bdo id='Fxuph'></bdo><ul id='Fxuph'></ul>
                    1. <small id='Fxuph'></small><noframes id='Fxuph'>

                    2. <i id='Fxuph'><tr id='Fxuph'><dt id='Fxuph'><q id='Fxuph'><span id='Fxuph'><b id='Fxuph'><form id='Fxuph'><ins id='Fxuph'></ins><ul id='Fxuph'></ul><sub id='Fxuph'></sub></form><legend id='Fxuph'></legend><bdo id='Fxuph'><pre id='Fxuph'><center id='Fxuph'></center></pre></bdo></b><th id='Fxuph'></th></span></q></dt></tr></i><div id='Fxuph'><tfoot id='Fxuph'></tfoot><dl id='Fxuph'><fieldset id='Fxuph'></fieldset></dl></div>
                      <legend id='Fxuph'><style id='Fxuph'><dir id='Fxuph'><q id='Fxuph'></q></dir></style></legend><tfoot id='Fxuph'></tfoot>