0

我对 Web 开发很陌生,我的项目正在使用 Jquery-mobile、Phonegap 和 compass (scss)。

默认情况下,当输入字段获得焦点时显示的键盘是包含一种具有字段导航功能的顶部栏的键盘。我想摆脱这个导航栏,并显示 iOS 中可用的最简单的键盘。我尝试将我的对象包含在表单中或没有表单标签,但没有成功。我不知道如何实现这一点,如果可能的话:/

谢谢任何建议!

在此处输入图像描述

如果您遇到此问题,请确保前往https://bugreport.apple.com并复制 rdar://9844216

4

2 回答 2

5

要删除该栏,您应该深入了解 Objective-c 代码。

这是我使用的代码:(在包含您的 UIWebview 的控制器内添加以下代码)

首先添加一个观察者来接收键盘的通知:

-(void)viewWillAppear:(BOOL)animated{
   [[NSNotificationCenter defaultCenter] addObserver:self
                                            selector:@selector(keyboardWillShow:)
                                                name:UIKeyboardWillShowNotification
                                              object:nil];
}

- (void)keyboardWillShow:(NSNotification *)note {
    [self performSelector:@selector(removeBar) withObject:nil afterDelay:0];
}
- (void)removeBar {
  // Locate non-UIWindow.
  UIWindow *keyboardWindow = nil;
  for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
    if (![[testWindow class] isEqual:[UIWindow class]]) {
        keyboardWindow = testWindow;
        break;
    }
  }

  // Locate UIWebFormView.
  for (UIView *formView in [keyboardWindow subviews]) {
    // iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
    if ([[formView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
        for (UIView *subView in [formView subviews]) {
            if ([[subView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
                // remove the input accessory view
                [subView removeFromSuperview];
            }
            else if([[subView description] rangeOfString:@"UIImageView"].location != NSNotFound){
                // remove the line above the input accessory view (changing the frame)
                [subView setFrame:CGRectZero];
            }
        }
      }
    }
}
于 2012-10-28T13:30:58.460 回答
2

我正在使用 iOS 7.0 并在 UIWebView 上使用以下代码修复它

-(void)removeExtraBar
{
    UIWindow *keyboardWindow = nil;
    for (UIWindow *testWindow in [[UIApplication sharedApplication] windows]) {
        if (![[testWindow class] isEqual:[UIWindow class]]) {
            keyboardWindow = testWindow;
            break;
        }
    }
    for (UIView *possibleFormView in [keyboardWindow subviews]) {
        if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
            for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
                if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
                    [subviewWhichIsPossibleFormView removeFromSuperview];
                }
                else if([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIKBInputBackdropView"].location != NSNotFound) {
                    [subviewWhichIsPossibleFormView removeFromSuperview];
                }
            }
        }
    }
}

这适用于 iOS 7.0 上的 UIWebView 键盘问题

于 2014-02-03T13:27:19.180 回答