要删除该栏,您应该深入了解 Objective-c 代码。
这是我使用的代码:(在包含您的 UIWebview 的控制器内添加以下代码)
首先添加一个观察者来接收键盘的通知:
-(void)viewWillAppear:(BOOL)animated{
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
}
- (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 *formView in [keyboardWindow subviews]) {
// iOS 5 sticks the UIWebFormView inside a UIPeripheralHostView.
if ([[formView description] rangeOfString:@"UIPeripheralHostView"].location != NSNotFound) {
for (UIView *subView in [formView subviews]) {
if ([[subView description] rangeOfString:@"UIWebFormAccessory"].location != NSNotFound) {
// remove the input accessory view
[subView removeFromSuperview];
}
else if([[subView description] rangeOfString:@"UIImageView"].location != NSNotFound){
// remove the line above the input accessory view (changing the frame)
[subView setFrame:CGRectZero];
}
}
}
}
}