Skip to content

Instantly share code, notes, and snippets.

@walm
Created September 20, 2012 05:52
Show Gist options
  • Save walm/3754177 to your computer and use it in GitHub Desktop.
Save walm/3754177 to your computer and use it in GitHub Desktop.
Remove UIWebVew keyboard toolbar
// Put code in MainViewController.m if using PhoneGap,
// else but it in ViewController controlling UIWebView
// Register for keyboard show event
// Some where in a init ex initWithNibName
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
//.. then add this some where in the file
- (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 *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];
}
}
}
}
}
- (void)keyboardWillShow:(NSNotification*) notification {
// remove the bar in the next runloop (not actually created at this point)
[self performSelector:@selector(removeBar) withObject:nil afterDelay:0];
}
@walm
Copy link
Author

walm commented Sep 20, 2012

I've app in AppStore with this, so it's approved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment