There is another level to this.
- If you do not have an inputAccessoryView, you will not receive a notification as above.
- However, if you have configured inputAccessoryView for the text view, you will still receive a UIKeyboard notification when external kbd is present - the logic is that you will need to animate your view in the right place so that you need the animation information contained in the notification.
Fortunately, in this case there is enough information to find out if kbd will be provided, although it is still a bit involved.
If we look at the notification dictionary, we will see this information:
UIKeyboardFrameBeginUserInfoKey = NSRect: {{0, 1024}, {768, 308}} UIKeyboardFrameEndUserInfoKey = NSRect: {{0, 980}, {768, 308}}
It was in a portrait; if we rotate the device to PortraitUpsideDown, we get:
UIKeyboardFrameBeginUserInfoKey = NSRect: {{0, -308}, {768, 308}} UIKeyboardFrameEndUserInfoKey = NSRect: {{0, -264}, {768, 308}}
Similarly, in LandscapeLeft and LandscapeRight we get different start and end locations.
Hmm ... what do these numbers mean? You can see that kbd is turned off to start, but it is moving a bit. To make things worse, depending on the orientation of the device, the kbd locations are different.
However, we have enough information to find out what is happening:
- kbd moves only from the screen on the physical bottom of the device to the same height as inputAccessoryView (but hides from it).
- So, in the case of a portrait, it moves from 1024 to 980 - we should have an inputAccessoryView with a height of 44, which is really so.
- Thus, in the portrait, if the end is y +, the height of the input_select height == screen height, then kbd is not displayed. You need to handle other rotations, but this is an idea.
user721239 Apr 22 '11 at 23:13 2011-04-22 23:13
source share