iPhone Keyboard key value return - iphone

I would like to know if a method like touchesBegan for touches Event exists for the iPhone keyboard. I mean just how to know when I press a key, which value is it. (Don't display it on UITextfield or UILabel but display it with an NSLog for example).
Is there any way?

You want the UITextFieldDelegate Protocol method:
– textField:shouldChangeCharactersInRange:replacementString:
The keyboard sends this every time a key is pressed so you can decide if you want to display the character associated with the key or perform some other action.

Accessing the keyboard view direct is strictly undocumented, so don't think of applying it to any AppStore apps.
However, you can make an off-screen text field, and use it to capture keyboard input.

Related

are you able to type into a UILabel

Hi I am wondering if you are able to use the ios keyboard to update a textfield as the user types?
you could get each character as they type through UITextFieldDelegate delegate methods,
Once you get the set of character through delegate method , you could update you UILabel.
If you're talking about UITextField, then yes, naturally, those are meant to be modified by the user and interact with the keyboard just fine. If you're talking about UILabel, then no, the user can't type directly into a label, but as #Jhaliya suggests you could update the label whenever the user changes a text field, text view, or other object that can interact with the keyboard.

Does Control in IPhone has Lost Focus Action?

In Vb.net we have that sort of thing right.
However, in beginning IPhone development, by David Mark, the way the author implement removing keyboard when a user tap outside the text box is by turning the whole view into a control and then create an IBaction for that view being touch.
Why not the text box touch up outside or touch down outside? Is this the normal way?
Yes it is the normal way of doing out of focus. Or you can implement UITextFieldDelegate metod textFieldShouldReturn. Where you call resignFirstResponder for a particular text field.

UITextView with "Done" button *and* "Return" key?

I use a UITextView for multiline text entry in my iPhone app, and I have set the "Return" key to display "Done." I've also set up the return key to disable first responder status, so that hitting "done" actually exits the UITextView. However, I also want to enable users to be able to enter multiline text into the UITextView, i.e. to be able to use the "Return" key. Is there any way to make this work on the iPhone/iPad's UI?
I've been struggling with this issue for 5 years waiting for apple to wake up and create some sort of solution for the textfield multiline responding to done button until I decided to create one myself.
there you go:UITextField multiline with hide keyboard option
It'll be time consuming but you could create your own keyboard with both these keys (this can be done by specifiying the Input View for the UITextView ).
Another alternative could be having a button that sits just above the keyboard that would dismiss the keyboard. You can use the UITextView's Input Accessory View which allows you to create a view that sits on top of the keyboard. See here for more information (I'm aware this document is for iPad but it works for all iOS devices - also just to note, both these require iOS 3.2 or greater).
This should only need to be done on the iphone because the iPad keyboard already comes with a dismiss keyboard button as well as a return button.

How to set the popup keyboard to only show certain keys?

How do you set the popup keyboard to only show certain keys when you type into a textfield? I know there are default keyboards but none seems suitable. Is there an alternative input option? Thanks.
Since iOS 3.2, you can change the keyboard :
cf.
Official documentation here
Discussion
The value of this property is nil.
Responder objects that require a
custom view to gather input from the
user should redeclare this property as
readwrite and use it to manage their
custom input view. When the receiver
subsequently becomes the first
responder, the responder
infrastructure presents the specified
input view automatically. Similarly,
when the view resigns its first
responder status, the responder
infrastructure automatically dismisses
the specified view.
This property is typically used to
replace the system-supplied keyboard
that is presented for UITextField and
UITextView objects.
Apple wont allow you to do any alterations to the keyboards..
What do you want to enter? Either create a custom keyboard, use pickers if possible or code it to not accepts certain keys..
Okay. I did'nt know you were allowed to change the keyboard now..
I usually use a picker. and have one of the segments just contain a "," the rest of the segments are 0-9..
or you could do something like this:
What is the best way to enter numeric values with decimal points?
But since its okay to change the keyboard now try this:
http://blog.devedup.com/index.php/2010/03/13/iphone-number-pad-with-a-decimal-point/

Detect what's being inputed in a UITextField

I have a UITable View with a textfield that is editable right on the view (like Phone in contacts, etc.). I want to enable/disable my save button conditional up text being present in this field. So, I want the button to start out as disabled (for a new record) and then, as soon as I type the first letter into my text field, I want the button enabled. If I delete again back to zero, I would like the button disabled. You get the point.
Now, for doing this I need some way to detect the text being inputed while the user writes it (and when he finishes editing).
Does anybody know how to do this?
Thanks a lot. Still noob...
Try this: (from the Apple documentation for UITextInputTraits)
enablesReturnKeyAutomatically
A Boolean value indicating whether the return key is automatically enabled when text is entered by the user.
#property(nonatomic) BOOL enablesReturnKeyAutomatically
Discussion
The default value for this property is NO. If you set it to YES, the keyboard disables the return key when the text entry area contains no text. As soon as the user enters any text, the return key is automatically enabled.
Have your view controller adopt the UITextFieldDelegate protocol, and then implement a couple of the protocol's methods:
– textFieldDidBeginEditing:
– textFieldDidEndEditing:
Also, be sure to set the text field's delegate property to point to your view controller. The text field will then automatically send these messages to the controller when editing session begins and ends.