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.
Related
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 :)
I want to create a UIKeyboard type that will look like the following.
This app is only for iPad and none of the default keyboard type seem to match.
Any suggestions for adding buttons to the keyboard type?
I may be wrong, but what that looks like is the standard keyboard with a custom toolbar on top. It was most likely done using the inputAccessoryView property for the textfield:
[textField setInputAccessoryView:inputAccView];
Here is where I took the example from.
As far as I am aware, this is not supported in a super easy way by default iOS system keyboards.
However, you can specify your own UIView as an "input accessory view" for a text field.
Specifically, look at this method in the UITextField documentation:
inputAccessoryView.
So you should just be able to create a UIView, style it to look very similar to the usual system keyboard UI, add UIButtons, and set it as the "input accessory view"
But you will have to do your own work to make the background of the accessory view and the buttons on it fit well with the system keyboard.
I want to realize the function: when I click a button, a interface of keyboard will come out in a dependent interface. How can I do it? Just for iOS.
You need to add to your current view UITextField with frame = CGRectZero, create a reference to that textField in code and then on pressing button call becomeFirstResponder on textField.
You need to add an UITextField to your view and call then [myTextfield becomeFirstResponder]; Its possible to set the hidden attrribute from UITextField to YES - so the user will never see the textfield. After Keyboard input is finished you can remove the UITextField with removeFromSuperview.
Maybe a little bit dirty,but thats the solution I used often. I wonder if the SDK provide another possibility.
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?
I have a UITextView field meant to receive input from a keyboard.
But the standard keyboard not being adequate for my app, I built another one with the buttons and characters I need.
I would normally make use of the UITextViewDelegate protocol and things would work.
But in this situation, how do I connect the UITextView field and my new keyboard?
Is there a "best way to do it"?
Thanks in advance for any relevant information.
Set your custom view as inputView of the UITextView.
// Edit: additional information:
Your custom keyboard will be a collection of buttons. You can add the same selector as target for all those buttons. Than your callback could be:
- (void) buttonTouched: (UIButton*) button
{
myTextView.text = [myTextView.text stringByAppendingString: button.text];
}