UITextField in a storyboard static UITableViewCell is not accepting input - ios

I have created a static tableview cell containing a UITextField using storyboards in Xcode 4.5.2 (this also happens in 4.6 DP1). Tapping on the UITextField brings up the keyboard, but the text field does not accept input from the keyboard. If I add text to the field programatically, the text will appear, but I am still not able to add text via the keyboard (or via the main keyboard when using the simulator). The only key that does work on the keyboard is the "Delete" key. Has anyone experienced this and know what the cause may be?

Does the textField has IBOutlet property, and also you connect IBOutlet in storyboard?

Related

Showing the textfield directly above keyboard when editing

I would like to try and make the text field appear above the keyboard when in editing mode, as shown in this picture, which is in the app Clash of Clans:
Is this achievable through some code or doing stuff in the Interface Builder, or have Supercell (makers of Clash of Clans) done this themselves?
You should look into the inputAccessoryView.
As it says here:
This property is typically used to attach an accessory view to the system-supplied keyboard that is presented for UITextField and UITextView objects.
You add the inputAccessoryView to the individual UITextField and UITextView views you have on your page, meaning that you can have separate inputAccessoryViews for the various textfields if so desired.
So in your case you would need to create your own view containing a UITextField and that checkmark button you have on the right and then add that view as a inputAccessoryView to your textfields and then it should appear right above your keyboard.
Hope that is enough to get you started, now you at least know that you should search for inputAccessoryView to see what can be done :)

Misuse of UITextField.inputView to get similar popup behavior of keyboard

I often want to put my own things in the same place the keyboard pops up, but for my own controls... such as putting a UIDatePicker there, or a custom UIPickerView, or whatever.
I came up with a clumsy way of getting this behavior by having a dummy UITextField and putting my custom view in its inputView property. Then when the user clicks on my item, I just trigger off the UITextField to display the view I've assigned to the inputView.
Then I got to wondering if there was a better less kludgey way to do this. I found this article Show UIPickerView like a keyboard, without UITextField where several people recommend the same thing I do.
My question is this. Is it common to (mis)use the UITextField in this manner?
Many times you will face a UITextfield that you would want to populate through a custom control other than the standrd keyboard. Thus the inputView method was declared and can be used.
What is recommended:
1- if the UItextfield is normal, use the keybard (don't change the input view)
2- if the value is numeric, show the numberpad in keyboard directly (textField.keyboardType = .numberPad)
3- if your textField is a date then you set the input view as a date picker.
4- sometimes you need a UITextField where you need to choose between stuff. Thus you develop your own custom UIPicker and set it as an input View.
5- If what you are tring to achieve don't fall in all the above then you can do your own inputView and assign it.
So in short don't be afraid, it is the normal thing to do!
Hope this helps!

Is it possible to add a Done key to ALL keyboards in an app?

Is it possible to add a done or cancel key which dismisses a keyboard to all keyboards in an iOS app? There are several posts asking how to dismiss a keyboard via a cancel or done button, but the solutions are on a field by field basis.
Are there any solutions that add this functionality globally so the code wont need to be duplicated for each textfield/area in an application?
Like #silentBob says in his answer, the inputAccessoryView of a text field is the view that’s displayed immediately above the keyboard when the text field is the first responder. If you didn’t want to write an extension on UITextField to override the -inputAccessoryView method, you could also create a subclass of UITextField to do the same, which would make it easier to determine which method is going to be called. You could also have multiple subclasses of UITextField to customize which button(s) appear. If you have a text field in a storyboard, you can simply change the class to your custom subclass, so while you have to go through and make those changes, you don’t have to do it in code.
Yes, you can add an extension to UITextField class, which should add a UIToolbar with Done and Cancel actions as UITextField inputAccessoryView.
Well, In that case you have to customise the keyboard, built your own keyboard and do whatever you need to do with your key in the keyboard.

Accessible Custom Keyboard in iOS

I want to make a custom keyboard perform like the iOS software keyboard with regards to accessibility. When a button-press adds a letter to a UITextField, the letter should be spoken by VoiceOver in the ‘added character tone‘. When a button-press deletes a letter from a UITextField, the letter should be spoken by VoiceOver in the ‘deleted character tone’.
Here is what I attempted:
Created a UITextField in the view controller, in the storyboard.
Created two UIButtons labeled ‘Type’ and ‘Backspace’ in the view controller, in the storyboard.
Set the accessibility traits for both UIButtons to Keyboard Key.
Hooked the storyboard UITextField up to an IBOutlet UITextField instance, textField.
Hooked the storyboard ‘Type’ UIButton up to an IBAction, -type.
Hooked the storyboard ‘Backspace’ UIButton up to an IBAction, -backspace.
Implemented -type as: [[self textField] insertText:#"a"];.
Implemented -backspace as: [[self textField] deleteBackward];.
Made textField the first responder.
I also tried the same thing, moving the buttons into a UIView that was set as textField’s inputView.
The characters are properly added to and removed from the text field, but they are not spoken by VoiceOver. How can I make this work?
EDIT:
The hardware keyboard speaks correctly. It is only the custom software keyboard that is not speaking as it should.
I noticed that to get “Spoken Content” » “Speak Screen” to speak the keyboard keys, too, I had to add the .keyboardKey to the button accessibilityTraits, e.g. in Swift:
button.accessibilityTraits = [.keyboardKey]
Or in Objective-C:
[button setAccessibilityTraits:UIAccessibilityTraitKeyboardKey];
And, obviously, if your buttons are images, you’ll want to add explicit accessibilityLabel for them, too.
Voice Over may need to be enabled for the whole device for this to work. You can change this in accessibility. I'm not ure what to do if voice over is already enabled on the device.

How to connect a Text View with a UITextField outlet , in iOS?

I have a problem that really drives me crazy.
A few months ago i started developing an iphone application , and i needed to have a multiline textField so that the user could write some comments. In the end , because at the time i couldnt find a solution , i found a solution how to use a Text View instead which is by default multiline. In my project it seems that i have connected this Text View with a UITextField outlet.
Now i am trying to make my app universal , so i created a new .xib file for the iPad version.
However it seems impossible to connect the Text View that i created with the UITextField Outlet that i was using with the iphone .xib.
I m really breaking my head here to remember how on earth i connected these two in the first place. I remember that i implemented some delegate methods to customize the Text View to work as a Text Field , and it seems that all the properties of my iPad Text View are the same with the ones of the iPhone version. However i cant connect it with the outlet.
Does anyone have any idea , what i am missing here?
It is imposible connect UITextView to UITextField. There is no solution or tweak using which you can alter UITextView to behave like UITextField. You better use some third party library and use it in your project. I am still surprised how you did it in your iPhone project. Can you please share some code how you did in iPhone for better understanding of what you are asking.
Outlets can be connected to the same types only and they are pointing to the object of the same types and they have 1-to-1 relationship, you can not connect one outlet to multiple objects either.
You might have named your UITextView as UITextView *textField or something , you need to Connect your UITextField outlet to the corresponding textField in your classes, you can not connect UITextField to UITextView.
It appears that after all is possible..
I tried the unthinkable and it worked..
I created a new outlet from my text View , a UITextView outlet and then... well i just renamed the UITextView to UITextField and works perfectly.. I connected both textViews (iPhone.xib and iPad.xib) in this outlet and it works.. (I connected them before renaming it to a UITextField outlet cause after that you cant connect them)

Resources