I can remove the toolbar but I am left width a blur of the height the toolbar was.
Any idea on how to remove this?
The code below is the function. It's pretty straight forward. I use this in a webview using phonegap.
-(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) {
// remove the border above the toolbar in iOS 6
[
[possibleFormView layer] setMasksToBounds: YES];
for (UIView * subviewWhichIsPossibleFormView in [possibleFormView subviews]) {
if ([
[subviewWhichIsPossibleFormView description] rangeOfString: @"UIWebFormAccessory"].location != NSNotFound) {
[subviewWhichIsPossibleFormView removeFromSuperview];
// http://stackoverflow.com/questions/10746998/phonegap-completely-removing-the-black-bar-from-the-iphone-keyboard/10796550#10796550
UIScrollView * webScroll;
if ([
[
[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
webScroll = [
[self webView] scrollView];
} else {
webScroll = [
[
[self webView] subviews] lastObject];
}
CGRect newFrame = [webScroll frame];
float accessoryHeight = [subviewWhichIsPossibleFormView frame].size.height;
newFrame.size.height += accessoryHeight;
[subviewWhichIsPossibleFormView removeFromSuperview];
[webScroll setFrame: newFrame];
}
}
}
}
}
If you hit this problem, make sure to head over to https://bugreport.apple.com and duplicate rdar://9844216
See Question&Answers more detail:os