How to make keyboard with textfield on the top of it? - iphone

I need to have textfield (maybe with button) fixed at the bottom of screen, and when start editing, I want it (and probably the whole view) to move with keyboard up - just like in the native Messages application (or Whatsapp, etc...). Any suggestions ?

The easiest way is to put everything in a UIScrollView, which you resize when the keyboard is shown using the UIKeyboardDidShowNotification. Then you scroll to ensure that your views are visible.
Check out the Apple documentation under "Moving Content That Is Located Under the Keyboard"

Related

UIView container to autoscroll on keyboard resize

I have a UIViewController, it's a view (UIView) containing two elements - UIPageControl and also a UIScrollView. Now, when using normal keyboard, the view is a perfect fit, sharing the screen with the keyboard. But when an international keyword is used, the keyboard would add an extra ribbon for showing the international characters. When that's happened, the view would be covered by the extra keyboard ribbon. The view can't be resized as the UIScrollView view contains a table of two rows of fixed size. So now I am wondering if I should find a way to allow the UIView container to up shift to accommodate the ribbon and shift back when the ribbon disappears. Or is there any other better solutions to work around the issue?
Check out my answer to this stackoverflow post here: detect the appear and disappear of international keyboard
Basically, you'll want to sign up to receive notifications about when the keyboard is shown. From there you can get the keyboard frame size and then adjust views in your window to display properly. The tutorials in the post really do a good job explaining how to do this. Check them out! If you still have questions I can try to help you with specifics.

iPhone Keyboard Adjust In View

I've been searching, but haven't quite found a complete answer, and the Apple docs aren't much help.
I have an application with a UIView that has a lot of text fields on it, ranging from the top of the view to the bottom. When the user clicks the first UITextField the keyboard pops up. The keyboard has three buttons above it, previous, next, and done on a toolbar InputAccessoryView.
Basically, let's say there are 6 UITextField boxes that space from the top of the view to the bottom. When the user gets past the third text field, the keyboard blocks the bottom three. How do I have the view adjust up when putting text in the bottom three text fields?
You need to place your textfields into a UIScrollView, and either translate the view above the keyboard when it is active and away when it is down, or another solution such as always having the keyboard up on that page, which'll save you the setFrame calls on your UIView/UIScrollView depending on what the keyboard is doing.
This will further help:
How to adjust the view position when the keyboard opens in iPhone?

Problem with UIScrollView and keyboard in iPhone

Let's see: i have to views each with a couple of textfields.
One was built regularly, the other one has more textfieds and components so i added a scroll, which works (sorta). The problem is that, now, when i touch one of the text fields the keyboard appears and it hides the components, it doesn't scroll "naturaly" like in the regular view with no scroll (there, you know, the keyboard appears and the view "moves" in order to show the active text field).
So how can i accomplish that from my scroll?
I hope i've been clear, i'm an iOS newbie.
Your answer should be found here.
How to make a UITextField move up when keyboard is present?

UIView accessibility issue

I've developed an iPhone App and most of it is accessible but I have an issue with one thing I do.
When the user clicks the settings button in the App (it has a main menu with a bunch of buttons for various Applications) I add a UIView on the top and and darken the background screen. Unfortunately for a blind person this UIView doesn't become "active", ie they are still navigating around the background screen.
I initially added the UIView using addSubview: and then tried insertSubview: atIndex: but neither have operated as expected.
Edit: Further information there are text fields and a button on this screen, perhaps I could instead make one of them active or something?? No idea how I would do this though.
How about using becomeFirstResponder? It makes the control receiving this message active and the receiver of input. For UITextView etc. it brings up the keyboard.
I didn't get what you are saying, but I thought there may be problem with the view added on the top.
Do one thing, if you added the view using interface builder then select the view and click on Layout menu in the Menu bar and select "Send to Back".
or else if you add that through code, then write code as
[self.view sendSubViewToBack:addedView];
Regards,
Satya

adding a textbox and a button at the top of the keyboard on iphone

I want to add a text box and a button beside it. They will be at the bottom of the window. Then, when I touch the textbox (to type something), keyboard will appear and the whole row (with textbox and button) scrolls up and the keyboard will be right below them. Could you please let me know how can I do that?
Is there any sample program?
Thanks.
Matt Gallagher posted this on his blog:
Sliding UITextFields around to avoid the keyboard
It is a step by step example of exactly what you want.
In the XCode documentation iPhone Application Programming Guide there is a section on "Moving Content That Is Located Under the Keyboard" that talks about receiving keyboard notifications when a keyboard is about to show. There's code there to show you how to get the keyboard size (which varies depending on the orientation). I won't repeat it here.
You can use the same technique to get the UIKeyboardWillShowNotification notification and get the height of where the keyboard will end up. That gives you the bottom edge of where your view needs to go, effectively putting it above the keyboard. So just put your textbox and button inside a view. When you get the notification tell your view where it needs to go (keyboard height + height of the container view) and you're done. You'll also want to catch UIKeyboardWillHideNotification to move the view back to where it was, so keep track of the original container view position.
It's pretty straightforward and it'll look nice, especially if you use a nice UIView animation effect and set the timing just right.