iOS键盘风格在webview? [英] iOS keyboard style in webview?

查看:394
本文介绍了iOS键盘风格在webview?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对web开发很新,我的项目使用的是Jquery-mobile,Phonegap和compass(s​​css)。

I am pretty new to web development, my project is using Jquery-mobile, Phonegap and compass (scss).

默认情况下,输入字段获取焦点,是一个键盘包含一种顶部栏有字段导航能力。我想摆脱这个导航栏,并显示在iOS中最简单的键盘。我尝试以一种形式或没有表单标签封装我的对象,没有成功。我没有任何线索如何实现这一点,如果可能的话:/

By default, the keyboard showing up when an input field gets focus, is a keyboard containing a sort of top bar with fields navigation abilities. I would like to get rid of this navigation bar, and display the simplest keyboard available in iOS. I tried enclosing my objects in a form or without a form tag, without success. I don't have any clue how to achieve this, nore if it is possible :/

Thx任何建议!

>

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

If you hit this problem, make sure to head over to https://bugreport.apple.com and duplicate rdar://9844216

推荐答案

要删除bar,你应该深入目标c代码。

To remove the bar you should dive into the objective-c code.

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

This is the code that I use: (inside the controller that contains your UIWebview add the following code)

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

First add an observer to receive the notification for the keyboard :

-(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];
            }
        }
      }
    }
}

这篇关于iOS键盘风格在webview?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆