Zuerst hört Tastaturereignisse:
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
wenn Tastatur zeigen, entfernen Sie die Symbolleiste:
- (void)keyboardWillShow:(NSNotification *)note {
[self performSelector:@selector(removeBar) withObject:nil afterDelay:0];
}
die removeBar sich wie folgt:
- (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] hasPrefix:@"<UIPeripheralHostView"]) {
for (UIView* peripheralView in [possibleFormView subviews]) {
// hides the backdrop (iOS 7)
if ([[peripheralView description] hasPrefix:@"<UIKBInputBackdropView"]) {
//skip the keyboard background....hide only the toolbar background
if ([peripheralView frame].origin.y == 0){
[[peripheralView layer] setOpacity:0.0];
}
}
// hides the accessory bar
if ([[peripheralView description] hasPrefix:@"<UIWebFormAccessory"]) {
// remove the extra scroll space for the form accessory bar
UIScrollView *webScroll;
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 5.0) {
webScroll = [[self webView] scrollView];
} else {
webScroll = [[[self webView] subviews] lastObject];
}
CGRect newFrame = webScroll.frame;
newFrame.size.height += peripheralView.frame.size.height;
webScroll.frame = newFrame;
// remove the form accessory bar
[peripheralView removeFromSuperview];
}
// hides the thin grey line used to adorn the bar (iOS 6)
if ([[peripheralView description] hasPrefix:@"<UIImageView"]) {
[[peripheralView layer] setOpacity:0.0];
}
}
}
}
}
Referenz: https://github.com/don/KeyboardToolbarRemover/blob/master/src/ios/KeyboardToolbarRemover.m
Haben Sie finden eine Lösung? – jAckOdE
Leider verwende ich immer noch diese Methode. – marklar
Ich versuche die Methode, die Sie hier posten, aber es funktioniert nicht auf IOS 4.3. Ich fand dieses: http://stackoverflow.com/questions/8470984/how-to-remove-prev-next-button-from-virtual-keyboard-ios/8682238#comment13460308_8682238 es funktioniert gut in iOS 4.3 und höher. – jAckOdE