How to make keyboard move along with scrollview? - ios

I have a scrollview and a searchbar in a controller. And I want the keyboard move along with the scrollview when the scrollview is being dragged. Just as when edit a message on iphone.
So what should I do and I will appreciate it if you can give me some code.
What I mean is when the searchbar is the first responder,there will be a keyboard ha ?
And if I scroll the scrollview ,the keyboard will move along with it.
Some one said I should listen some notification. Is it right?
Thank you very much.

You cannot move a keyboard along with the view.You can only change position of the view underneath it.Therefore, If you wish to move the keyboard along with the scroll....All You need to do is to make your own custom keyboard!!!!!

Related

How to move my chat input bar up on top with keyboard in Xcode?

I create a chat program. I've created my chat sequence using TableView. Now I have a view on the bottom of the page, contains one TextField and a send button. Now if I press on the TextField, the keyboard appears. I need to:
reduce the height of the tableView so that I still can see the most recent chat message, and return it to its former height if the keyboard is hidden.
move the view up to sit on top of the keyboard, and return it to its former position if the keyboard is hidden.
do both of things above with animation.
I'm still newbie in this keyboard + animation area. I only know I will need to implement textFieldDidBeginEditing and textFieldDidEndEditing to do this. But I don't know what code I should implement inside it. This answer provided some, but not the exact answer to my problem (it only moves the floating TextField in the scrollable view of TableView to be within the visible area, not moving a view not related with TableView). Any help or even article will be appreciated. Thanks!

Prevent scrollview from autoresizing

Im creating a basic messaging app with the message "bubbles" inside a scroll view. When the user first opens the screen the keyboard is not showing (besides an input box at the bottom), when they press the input box and start typing the keyboard with pop up (using NSNotificationCenter) a function will be called to resize the scrollview so that is no longer behind the keyboard.
That part all works well but when the user sends their message and a new bubble is added to the scrollview. The scrollview will automatically revert back to the size of the screen thus being behind the keyboard.
The scrollview is originally created in storyboard to take up the whole dimensions of the screen. So I suspect the cause of the resizing is due to some kind of message calling autolayout to update the scrollview when a subview is being added to it.
Im looking for a way to prevent the scroll view from reverting back to this autolayout when a subview is added to it, Thank you!
When the keyboard appears, adjust the UIScrollView's size by modifying its constraint's constants.

UIKeyboard will change frame with interactive keyboard dismiss, not called continuously

I am trying to use the UITableView.keyboardDismissMode = UIScrollViewKeyboardDismissMode.Interactive, to be able to drag my keyboard up and down. However I can't find any way to track the keyboard frame to update my tableView frame and messaging view. I am simply trying to replicate the standard iMessage behaviour. Given the name, I would have thought that UIKeyboardWillChangeFrameNotification would have been perfect for tracking the keyboard frame changes, but it only notifies when the gesture ends and the keyboard animates up or down.
I'm not sure if this will work but you could try to track the drag progress via the panGesture property on UIScrollView in your tableView. It wouldn't be a direct tracking of the keyboard frame, but if you know the keyboard's height and the progress/offset of the pan, you might be able to math your way around the problem.
The best approach for interactive dismissal is to use the "UIKeyboardDidShowNotification" and "UIKeyboardWillHideNotification" system notifications. When the selector is called you update the table's bottom inset. NOT the constraints. Updating the inset will give you a beautiful smooth keyboard dismissal experience.

how can i accomplish the effect of instagram comments in a UITable?

I want to accomplish the effect of instagram when we scroll in the comments and it hides the keyboard like this:
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
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.

Is it possible to slide in the keyboard from the side, rather than the bottom

When a control becomes the First Responder, normally the keyboard slides in from the bottom. How can I change that behavior and make it slide in from the left or the right instead? It makes much more sense for the particular UI that I'm working on.
Thanks
You could try to move the keyboard frame intercepting the UIKeyboardWillShowNotification event.
For retrieving the keyboard frame refer to this answer or this other one.
You could create your own view which functions as a keyboard.

Resources