3

I want to accomplish the effect of instagram when we scroll in the comments and it hides the keyboard like this:

enter image description here

I know its not when the uitable scroll, because if you scroll and "don't touch" the text box it doesn't hide the keyboard, but if you "touch" the text box when scrolling it hide the keyboard.

And another question is how i can show/hide keyboard in a specific location, i mean, to accomplish this effect.

UPDATE

I found a solution HERE for someone who want to accomplish this too :D

FxckDead
  • 408
  • 6
  • 16

1 Answers1

2

Set the keyboardDismissMode of the table view to UIScrollViewKeyboardDismissModeInteractive. Now, as you pan your finger over the keyboard, while scrolling the table view, the keyboard will follow your finger and interactively dismiss. This is all done by the system for you.

Léo Natan
  • 56,823
  • 9
  • 150
  • 195
  • it works !! but how can i take the keyboard coordinates to move the comment box while its moving? (just like instagram) – FxckDead Dec 06 '13 at 00:45
  • You cannot move the keyboard yourself. Anything related to the keyboard is private API. – Léo Natan Dec 06 '13 at 00:46
  • i want to move the comment box while the keyboard is moving, i found this answer [link](http://stackoverflow.com/a/9136698/392978) but this notification isn't in real time so only works when the keyboard appears and when it its hiden, so the textview dont move with the keyboard :( – FxckDead Dec 06 '13 at 01:20
  • 1
    Ah, I see now what you mean. You should add the comment box as an input accessory. It will then be attached to the keyboard. Read about `inputAccessoryView`. – Léo Natan Dec 06 '13 at 01:24
  • but this View as InputAccessoryView when the keyboard was "gone" will be gone too right? – FxckDead Dec 06 '13 at 01:32
  • Yes, but you can add a "impostor" view that looks similar, so it appears as if it is there. Once the user taps the text view, again pops the keyboard with the accessory. – Léo Natan Dec 06 '13 at 01:35
  • i was trying to accomplish this, BUT, there is a problem, if you see the instagram implementation, you can see that the scroll view is moving with the keyboard; When keyboards appears the scroll view apparently is resized or something like that? and when u scroll its above the keyboard and if the keyboard is animating the scroll still "attached" to the keyboard, if u can see instagram maybe you will understand my point (i hope i make a point, i'm not a master in english yet jeje) – FxckDead Dec 06 '13 at 02:15
  • Try another approach. Listen to `UIKeyboardDidChangeFrameNotification` and take the frame from there. Move the input view according to the keyboard frame. Just remember to not move it below the end of the main view. – Léo Natan Dec 06 '13 at 02:20
  • finally i stayed with the implementation where i only move the textbox on show/hide keyboard and not when it moves, but thanks a lot ! – FxckDead Dec 09 '13 at 18:28