我通过隐藏默认键盘使用自定义键盘进行webview。但是每当我点击输入框时,我的代码都会崩溃。它说
-[UITextInteractionAssistant containerIsTextField]: message sent to deallocated
经过大量调试后我发现[self.view endEditing:YES];是UITextInteractionAssistant可重用的。
有人可以提供帮助吗?
提前帮助!!!
// register for keyboard show event
[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification
object:nil];
隐藏UIWebviewAccessary
-(void)keyboardWillShow:(NSNotification *)note {
[self.view endEditing:YES];
[self removeBar];
[self performSelector:@selector(adjustFrame) withObject:nil afterDelay:0.03];
}
- (void)adjustFrame {
[self.webView stringByEvaluatingJavaScriptFromString:@"window.scroll(0,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];
}
}
}
}
}