1
我的項目包中有一個由我的UIWebView顯示的HTML文件。我想在UIWebView中編輯輸入時隱藏ios鍵盤並顯示我自己的虛擬鍵盤(用Jquery編寫)。在UIWebView中編輯內容時是否可以隱藏鍵盤?我不能爲元素使用blur()方法,因爲我想編輯內容。我需要這樣做沒有ios鍵盤?編輯內容時隱藏鍵盤UIWebView
SOLUTION
我找到了解決辦法。
- (void)viewDidLoad
{
NSString *path = [[NSBundle mainBundle] pathForResource:@"index" ofType:@"html"];
[self.webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:path]]];
self.webView.delegate=self;
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:nil];
[super viewDidLoad];
}
- (void)esconde {
for (UIWindow *keyboardWindow in [[UIApplication sharedApplication]
windows])
for (UIView *keyboard in [keyboardWindow subviews])
if([[keyboard description] hasPrefix:@"<UIPeripheralHostView"]
== YES) [keyboard removeFromSuperview];
}
- (void)keyboardWillShow:(NSNotification *)aNotification {
[self performSelector:@selector(esconde) withObject:nil afterDelay:0];
}
如果您找到答案,請將其作爲答案發布,然後接受答案,以便其他人在不需要時不會嘗試尋找解決方案。通過顯示你找到了他們可能遇到的問題的解決方案,它也可以幫助他人。 – CaptJak
我收到一條警告,「你不能在兩天內接受你的答案」 – amone