2011-04-21 22 views
1

我的應用程序中的一個屏幕顯示了帶有HTML Web窗體的UIWebView。目前,當一個文本框被關注並且鍵盤出現時,會顯示一個Go按鈕。目前我沒有Go按鈕的用戶,點擊它什麼也不做。如何禁用iPhone鍵盤當一個文本字段集中在UIWebView中時,可以使用Go按鈕嗎?

這怎麼按鈕可禁用或刪除,或我如何可以更改在一個UIWebView顯示鍵盤?

+0

你的意思是在web頁面或web頁面外的網頁的文本框? – Krishnabhadra 2011-04-21 12:28:20

+0

對不起,你的標題似乎textField是在UIWebView .. – Krishnabhadra 2011-04-21 12:45:45

回答

2

我認爲你唯一的選擇是爲調用註冊回來時,鍵盤會顯示並獲得一個UIView參考鍵盤和在鍵盤中的實際Go按鈕添加一個殘疾人找Go按鈕。

1)keyboardWillshow通知第一寄存器..

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil]; 

2)通過應用程序窗口的所有子視圖您keyboardWillShow功能遍歷去鍵盤參考..

UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1]; 

UIView* keyboard; 

//Iterate though each view inside of the selected Window 
for(int i = 0; i < [tempWindow.subviews count]; i++){ 
keyboard = [tempWindow.subviews objectAtIndex:i]; 
if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES){ 
//Keyboard is now a UIView reference to the UIKeyboard we want. From here we can add a subview 
//to th keyboard like a new button 
} 
} 

代碼耍賴在it..a非常翔實線程this link..Look複製..

我不知道是否有其他方法了there..Hope這將是有益的..

+0

我認爲'如果([鍵盤isKindOfClass:[UIKeyboard類]])'會更好。 – user500 2011-09-13 10:48:22

相關問題