2013-03-05 41 views
5

我如何找到UIKeyboard在我的應用程序中是否打開?如何知道UI鍵盤是否出現在iOS中?

我不想使用UITextField的任何委託方法。

請提出任何解決方案。

在此先感謝。

+0

請參閱[如何以編程方式檢查鍵盤是否存在於iphone應用程序?]的答案(http://stackoverflow.com/questions/ 1490573 /如何對編程 - 檢查 - 是否-A-鍵盤是至今功能於iphone-APP) – Bigood 2013-03-05 08:42:05

回答

5

測試這個:UIKeyBoard檢查狀態

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; 
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil]; 
4

From official Documentation.

使用鍵盤通知。

鍵盤聲明:

當系統顯示或隱藏鍵盤,這幾個職位鍵盤通知。這些通知包含有關鍵盤的信息,包括其大小,可用於涉及移動視圖的計算。註冊這些通知是獲取有關鍵盤的某些類型信息的唯一方法。系統爲鍵盤相關事件提供以下通知:

UIKeyboardWillShowNotification 
UIKeyboardDidShowNotification 
UIKeyboardWillHideNotification 
UIKeyboardDidHideNotification 
相關問題