Created
September 20, 2012 05:52
-
-
Save walm/3754177 to your computer and use it in GitHub Desktop.
Remove UIWebVew keyboard toolbar
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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]; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I've app in AppStore with this, so it's approved.