Reputation: 64834
The notification UIKeyboardWillShowNotification
is correctly broadcasted when a keyboard is available to the user.
I have my delegate method invoked when this happens, but how do I know if it is bluetooth keyboard or not ?
thanks
UPDATE
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification
object:nil];
Upvotes: 0
Views: 1381
Reputation: 131
The information is available in the userInfo dictionary, it just requires some manipulation to get what you want.
NSDictionary *userInfo = [aNotification userInfo];
CGRect startKeyboardRect = [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] CGRectValue];
CGRect finishKeyboardRect = [[userInfo objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
startKeyboardRect = [self.view convertRect:startKeyboardRect fromView:self.view.window];
finishKeyboardRect = [self.view convertRect:finishKeyboardRect fromView:self.view.window];
CGFloat vertShuffle = startKeyboardRect.origin.y - finishKeyboardRect.origin.y;
Upvotes: 1
Reputation: 5157
That notification (UIKeyboardWillShowNotification) will NOT be broadcast if a bluetooth keyboard is present unless you have an inputAccessoryView. That, in fact, is the only way to know. If you are using this to adjust views for the software keyboard, you should handle that based on this notification and you will always be ok.
Otherwise you can check the keyboard size differences in the userInfo property of the notification.
Upvotes: 0