How to display virtual keyboard in ios6 Simulator - ios

How do you display the virtual keyboard in ios6 Simulator (iphone or iPad) ? I've tried the toggle keyboard option, but nothing appears, can you only make it appear with code? and if so, how?
Thanks for any advice.

You can't show the keyboard without a 'target'. The system needs to know where it should send the entered text to.
So if you have a subclass of UIView that accepts text input (UITextField for example), the keyboard is either shown when the user taps that view or you can programmatically trigger it by calling:
[textField becomeFirstResponder];
From iOS-Documentation Managing the Keyboard:
Displaying the Keyboard
When the user taps a view, the system automatically designates that view as the first responder. When this happens to a view that contains editable text, the view initiates an editing session for that text. At the beginning of that editing session, the view asks the system to display the keyboard, if it is not already visible. If the keyboard is already visible, the change in first responder causes text input from the keyboard to be redirected to the newly tapped view.
Because the keyboard is displayed automatically when a view becomes the first responder, you often do not need to do anything to display it. However, you can programmatically display the keyboard for an editable text view by calling that view’s becomeFirstResponder method. Calling this method makes the target view the first responder and begins the editing process just as if the user had tapped on the view.
If your application manages several text-based views on a single screen, it is a good idea to track which view is currently the first responder so that you can dismiss the keyboard later.

Related

Why iOS default did not support auto keyboard dismiss function?

while I develop iOS application with swift, I wondered why apple did not support auto-dismiss keyboard function in application. This means if I implement a TextLabel on screen, I tapped that label, Keyboard appears, but did not dismissed automatically.
I thought many of application keyboards need to dismissed when users tap on outside of the keyboard screen or click 'done' button on a screen. However, basically, I have to implement keyboard dismiss function on every ViewController. And I think this is code duplication.
Anyone can explain me about apple's application method implementation philosophy and how can I wrote an reusable function, which is not duplicated function in every ViewController scheme.
Transposed from Comments:
In general apps where the main function utilizes the keyboard would rather control when the keyboard dismisses themselves instead on relying on an auto feature.
Ex: For a texting app after I click the send button I would like to send another text. Then I shouldn't dismiss the keyboard.
If you are dismissing the keyboard multiple times than I would try making a view controller class that handles that and subclass it. You can observe when the keyboard is shown and add a button on top of your view so when it is clicked the keyboard dismisses using [self.view endEditing:YES];

view resets when keyboard appears. ios 7

I'm writing an app where the controls provided can be hidden when required by the user to type text on the screen. the UI hides itself when the user taps the toolbar. but when he taps the text area all the changes made automatically undo themselves. the code just creates a textbox where the user taps and lets him type.
This is the first screen.
This is after the UI is hidden
And.. this is when the keyboard appears... the entire ui just pops up immediately.
Can anyone please tell my why this happens. and why my view resets everytime the keyboard shows.
Thanks.

switching between different inputViews for the same textfields

In my app, I have a textfield that takes its input from a picker view. However, the user could not find his preferred option so I added above the textfield a small button resembling a keyboard. Once the button is pressed the textfield's picker view should disappear and the keyboard should appear instead so that the user enter his preferred data. So how can I do that? I tried resigning it as first responder and then making it become the first responder hoping the picker could be released as the input view but it didn't work. Adding a textfield as an accessory input view will not look right (having two textfield the user should update the first one instead).

Different popover for editing and non editing text field

Ok, sorry if the title is a little off. Hope I explain it better here. What I want to do is have a popover (iPad app) that will do different things based on the state of a UITextField. So if the user is typing in that text field and then taps the popover button, the popover appears and if the user taps something in that popover it will get added to that text field (think something like adding often used text). In this situation the popover will only disappear when the text field finishes editing.
However if the user taps the popover button when the text field is not editing then that list of items still appears but now it should disappear if the user taps outside the popover.
I hear something about pass-through views, but I'm not certain that is what I need.
Does anybody know a good way to do this?
The passthrought views are views outside the popover that don't cause it to dismiss automatically. When you want to dismiss the popover from your code when the textfield has finished editing call [myPopover dismissPopoverAnimated:YES].
For adding text blocks into the textfield I think delegation is the right thing to do. You set the your main view as the delegate of the conten view of the popover and each time a text block in the popover is selected you tell the delegate to add this block to the textfields text.
When you want to prevent the popover from dismissing while the textfield is being edited you should implement the UIPopoverControllerDelegate methode popoverControllerShouldDismissPopover:.

2nd uitextfield in modal view not taking keyboard input

I am presenting my modal view using UIModalPresentationFormSheet and I am aware some have had issues resigning first responder and dimissing the keyboard in the past, but my issue is that the second textfield I pick I can't input text. This is hapenning in iPad simulator 4.3.
This happens if I select the second uitextfield while the keyboard of the first textfield is still visible. The cursor will move to the second textfield, but I am unable to edit it. Most of the time I am unable to click the bottom right button which would dismiss the keyboard in iPad, but if it works, I can then select the second textfield and be able to edit it.
Has anyone encountered these issues before?
I am also implementing
-(BOOL)disablesAutomaticKeyboardDismissal { return NO }
Even though this is not a solution it is a workaround. Basically you use a pagesheet instead of form, and resize it.
UIModalPresentationFormSheet resizing view
Even though this is not a solution it is a workaround. Basically you use a pagesheet instead of form, and resize it.
UIModalPresentationFormSheet resizing view

Resources