Slee
Slee

Reputation: 28248

prevent UIWebView inputs from displaying UIKeyboard without disabling user interaction

I have a UIWebView that loads and external product configuration web service UI that is basically a bunch of dependent Drop Down lists.

The problem is the Drop Downs are basically enhanced text input's so when the user taps them to display the options the UIKeyboard keeps popping up and own after they make their selection. it is less than a fluid process. Is there anyway to suppress the html inputs from triggering the UIKeyboard?

Upvotes: 2

Views: 2550

Answers (2)

WhiteTiger
WhiteTiger

Reputation: 1691

Then try this:

...
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(removeKeyBoard:) name:UIKeyboardDidShowNotification object:nil];
...

- (void)removeKeyBoard:(NSNotification *)notify {
    // web is your UIWebView
    [web stringByEvaluatingJavaScriptFromString:@"document.activeElement.blur()"];
}

remember to remove the notification and can filter it if only for your WebView object.

Upvotes: 3

WhiteTiger
WhiteTiger

Reputation: 1691

Try using the following code in the HTML:

<input type='text' width='100' onclick='blur()'>

with the method blur () and then you lose the focus will not appear on the keyboard.

Upvotes: 0

Related Questions