I need to know the current keyboard type. I was setting an instance variable in
- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
However, testing has shown that this is not always r开发者_StackOverflow社区eliable because of the asynchronous nature of notifications.
What I am wondering is if anyone can tell me how to determine the current keyboard type within a notification?
- (void)keyboardDidShow:(NSNotification *) {
// Need way to determine keyboard type here
}
Thanks.
If you are asking about the language of the keyboard that can be done only in iOS4.2 and above by using UITextInputMode class method: +[UITextInputMode currentInputMode];
If you want the size (because depending on the language the size can change) that is easy, get the size from object for key UIKeyboardBoundsUserInfoKey
- (void)keyboardWasShown:(NSNotification*)aNotification{
NSDictionary* info = [aNotification userInfo];
NSValue* aValue = [info UIKeyboardFrameEndUserInfoKey];
CGSize keyboardSize = [aValue CGRectValue].size;
//I just got the size! ... do something with it
}
精彩评论