Frage

I have a html file displayed by my UIWebView in my project bundle. I want to hide ios keyboard and show my own virtual keyboard (written in Jquery) while editing an input in UIWebView. Is it possible to hide keyboard while editing content in UIWebView? I can't use blur() method for an element because I want to edit content. I need to do this without ios keyboard?

SOLUTION

I found the solution.

- (void)viewDidLoad
{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
    self.webView.delegate=self;

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification object:nil];

    [super viewDidLoad];

}
- (void)esconde {
     for (UIWindow *keyboardWindow in [[UIApplication sharedApplication]
windows])
         for (UIView *keyboard in [keyboardWindow subviews])
             if([[keyboard description] hasPrefix:@"<UIPeripheralHostView"]
== YES)                             [keyboard removeFromSuperview];
}
- (void)keyboardWillShow:(NSNotification *)aNotification {
[self performSelector:@selector(esconde) withObject:nil afterDelay:0];
}
War es hilfreich?

Lösung

SOLUTION

I found the solution.

- (void)viewDidLoad
{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
    [self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
    self.webView.delegate=self;

    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(keyboardWillShow:)
                                                 name:UIKeyboardWillShowNotification object:nil];

    [super viewDidLoad];

}
- (void)esconde {
     for (UIWindow *keyboardWindow in [[UIApplication sharedApplication]
windows])
         for (UIView *keyboard in [keyboardWindow subviews])
             if([[keyboard description] hasPrefix:@"<UIPeripheralHostView"]
== YES)                             [keyboard removeFromSuperview];
}
- (void)keyboardWillShow:(NSNotification *)aNotification {
[self performSelector:@selector(esconde) withObject:nil afterDelay:0];
}
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top