Created
April 2, 2013 15:25
-
-
Save parse/5293074 to your computer and use it in GitHub Desktop.
Remove menu toolbar in keyboard on UIWebView. Credit to photokandyStudios
This file contains 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
- (void)webViewDidFinishLoad:(UIWebView*)theWebView | |
{ | |
// Black base color for background matches the native apps | |
theWebView.backgroundColor = [UIColor blackColor]; | |
// Register for notification center | |
[[NSNotificationCenter defaultCenter] | |
addObserver:self | |
selector:@selector(keyboardWillShow:) | |
name:UIKeyboardWillShowNotification | |
object:nil]; | |
return [super webViewDidFinishLoad:theWebView]; | |
} | |
- (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 *possibleFormView in [keyboardWindow subviews]) { | |
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView. | |
if ([[possibleFormView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) { | |
for (UIView *subviewWhichIsPossibleFormView in [possibleFormView subviews]) { | |
if ([[subviewWhichIsPossibleFormView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) { | |
[subviewWhichIsPossibleFormView removeFromSuperview]; | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not work on IOS 7